Load environment variables with dotenv

July 24, 2012 code 2 min read

I released dotenv, a handy Ruby gem that makes loading environment variables 100% less painful in development, guaranteed or your money back.


I love the emerging practice of storing application configuration in environment variables. It makes it ridiculously easy to keep secure data out of your code repository while still making it available at runtime. But it slightly complicates development. It’s not always practical to set all of those environment variables on your development machine or continuous integration server where you might run multiple projects.

Foreman provides this handy feature of loading variables from .env, which works great for anything that you want to put in your Procfile. But it doesn’t help you when you run your app manually, run a rake task, or open up the console. My co-workers got tired of me saying Works For Me™, so dotenv solves that problem.


For Rails 3 apps, dotenv will automagically load variables from .env into ENV whenever the environment is bootstrapped. For non-Rails apps, it’s a simple one-liner to load .env. Check out dotenv on GitHub for all the gory details.

This content is open source. Suggest Improvements.


avatar of Brandon Keepers I am Brandon Keepers, and I work at GitHub on making Open Source more approachable, effective, and ubiquitous. I tend to think like an engineer, work like an artist, dream like an astronaut, love like a human, and sleep like a baby.