Load Rubygems environment variables on startup (requie 'gemname' gives 'not found')

Small note to self (When I blog about something, I tend to remember it better).

On my new testing environment, I spent over twenty minutes figuring out why some gem would not be available. Once I figured out that somehow I needed to add require ‘rubygems’ I came to realize that on the new machine, I did not add a certain line to my bashrc, an environment variable was not set. Since my development and production machines have this set, I forgot about it alltogether (when something “just works”, why bother more mental effort on the matter?).

Here is the line to be added to your ~/.bashrc: export RUBYOPT=rubygems

After that, in all your ruby environments, gems are automatically available when ‘require’ing them. More on the matter at stackoverflow.

This article was published on webschuur.com. And migrated to this blog.


About the author: Bèr Kessels is an experienced webdeveloper with a great passion for technology and Open Source. A golden combination to implement that technology in a good and efficient way. Follow @berkes on Mastodon. Or read more about Bèr.