Carina C. Zona bio photo

Carina C. Zona

Email Twitter LinkedIn

Working on a server which only has Ruby 1.9.1 installed is a constant challenge. Hours wasted chasing "WTF?" bugs that turn out to be 1.9.1 itself misbehaving. Because they're triggered only under certain conditions, they're not widely known.

Upgrade to 1.9.2, where that's an option. But sometimes it's what we're stuck with. Or we're choosing to test against multiple version of Ruby to make sure it's backwards compatible.

So for the benefit of others using 1.9.1, here are some gotchas to be aware of:


"Error loading gem paths on load path in gem_prelude

In 1.9.1 patchlevels 329 and (current HEAD) 431, if the environment variable GEM_HOME is set, to any value, Ruby always starts execution with:

Error loading gem paths on load path in gem_prelude
can't modify frozen string
:69:in `force_encoding'
:69:in `set_home'
:38:in `dir'
:76:in `set_paths'
:47:in `path'
:286:in `push_all_highest_version_gems_on_load_path'
:355:in `'

RVM provides 1.9.1 patchlevel 378 and patchlevel 431. RVM sets GEM_HOME. The Ruby team patched 378, so it's not affected. The Ruby team has not patched 431.

In theory, RVM can compile with the gem_prelude patch. It's failing for me: "missing header for unified diff at line 5 of patch". But worth trying.

The gem_prelude bug also messes with the invaluable Bundler for gemset management.


When attempting to require a gem that definitely exists and is definitely on Gem.path, in some versions of 1.9.1, the require returns false anyway. If preceded by a gem statement ("gem 'somegemname'), both statements still return false. Interestingly, sometimes the gem statement will fail and yet the require doesn't.

Even when the require correctly returns true, Gem.loaded_specs doesn't populate.

But try this: call Gem.loaded_specs first, then (if necessary) gem statement, then the require. Voila, works!

These are just the most recent of my finds.

The big picture.

Finding help for 1.9.1 bugs can be difficult. It's considered so buggy that most, including the Rails team and man gem developers, have chosen to ignore and not support it. Which means that experience with its many bugs, and few fixes, is minimal even among those who are game to assist.