Peter Lyons

Environment Variables Considered Harmful

February 14, 2010

Many projects reference environment variables at either build time, install time, or run time to handle configuration that can't be made to work across all of the target environments. It is better to use plain text simple configuration files for the reasons that follow. First, let's quickly review common usage of environment variables.

So what's the problem with environment variables?

All of these reasons combined mean that in general environment variables are losers in our goal of managing complexity and making simple, easy to use software that is cross platform. So what's the solution? The solution, as it so often is, is simple plain text configuration files. At the end of the day, environment variables end up set in a shell script as KEY=VALUE type pairs, and that's where they belong in a configuration file on the filesystem. How does this make things better?

So go forth and configure with simple plain text configuration files. And there will be much rejoicing.