Frustrations With Environment Variables on Ubuntu

I am making a Rails app that I will run on Heroku. I will use Omniauth and Twitter for authorization, following one of the RailsApps templates.

The Twitter key and secret are kept in the config/initializers/omniauth.rb file. Instead of not tracking that file with git, I decided to use environment variables:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :twitter, ENV["TWITTER_KEY"], ENV["TWITTER_SECRET"]

I wanted to put them in a file that I could run before I ran my app locally. It looks like the only file that can load environment variables is .bashrc. I do not want to clutter my .bashrc file with variables that I only use for one app. I can set it at the console:

export KEY="some_value"

In my script, I tried every possible combination: With and without the word “export”, with and without quotes around the value, with and without a dollar sign in front of the key. I accepted that I should just put the commands in a text file, and then when I need to use the variables I just “more” the file, and then copy and paste the variables into the console. It took me an hour to finally think of that.