Skip to content

Instantly share code, notes, and snippets.

@schneems
Created October 3, 2013 23:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save schneems/6818433 to your computer and use it in GitHub Desktop.
Save schneems/6818433 to your computer and use it in GitHub Desktop.

On heroku compiles are done without environment variables. Why?

If you compile the same source code you will ge the exact same compiled app output every time.

This is determinisim. The app build is deterministic.

If you allow environment variables at build time, the output of the app is no-longer deterministic based soley on the code. You can deploy the same code and get different results.

If you are using user-env-compile your app builds are now non-deterministic.

Why is this bad?

It is harder to troubleshoot and reproduce problems. It means if you change your config, you techinally need to recompile your app every time.

Addon providers are allowed to change your environment variables (vendor prefixed for safety). But changing the variable does not trigger a new deploy. If you're app doesn't need user env compile this isn't a problem. Otherwise who knows.

Not only are you enabling your Heroku config to be availalble at compile/build/deploy time, you could be affecting internal environment variables as well like $PATH or $GEM_HOME, and if you mess those up, there isn't much we can do to fix them.

In short: Best practice is to not use user-env-compile.

@nathany
Copy link

nathany commented Feb 14, 2014

Is user-env-compile required for altering BUNDLE_WITHOUT? Seems to be:
https://blog.heroku.com/archives/2011/2/15/using-bundler-groups-on-heroku

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment