title: How to add .env file or otherwise set environment variables in a Heroku app?
body: <p>I've tried many different solutions on the web for this problem, but all have been unsuccessful.</p>
  
  <p>Here's the problem: My app needs to know whether it is being run on Heroku (production mode) or locally (development mode). For this purpose, we want to use environment variables. I've understood that environment variables on Heroku can be set in a <code>.env</code> file. So my attempt was to run <code>heroku run bash -a &lt;app-name&gt;</code> and then to install vim by doing this:</p>
  
  <pre><code>mkdir ~/vim
  cd ~/vim
  
  # Staically linked vim version compiled from https://github.com/ericpruitt/static-vim
  # Compiled on Jul 20 2017
  curl 'https://s3.amazonaws.com/bengoa/vim-static.tar.gz' | tar -xz
  
  export VIMRUNTIME="$HOME/vim/runtime"
  export PATH="$HOME/vim:$PATH"
  cd -
  </code></pre>
  
  <p>Apart from crashing repeatedly, vim didn't work anymore when I logged in and out of the shell:</p>
  
  <pre><code>~ $ vim // in the heroku shell
  vim: error while loading shared libraries: libXt.so.6: cannot open shared object file: No such file or directory
  </code></pre>
  
  <p>I also tried <code>heroku plugins:install heroku-vim</code> but running <code>heroku vim</code> after that only resulted in a long delay followed by the normal heroku shell opening, no vim.</p>
  
  <p>I don't really care if I get vim to work. I just want to be able to write in a file named <code>.env</code> on Heroku so I can set environment variables in it.</p>
  
  <p>How can I achieve this?</p>