Hello to everyone.
On Gentoo linux, I have installed both ruby 1.9.2 and ruby 1.8.7, both
installed using emerge (the Gentoo package manager). This setup contains
executable (rubygems version 1.3.7) which uses ruby 1.8, called gem18
which uses ruby 1.9, called gem19. Yesterday, I was surprised to find
gem18 installs gems in /usr/local/lib/ruby/gems, while gem19 installs
under /usr/lib/ruby/gems and started to investigate the reason for this.
After looking at the changelog of the Gentoo package, I discovered that
packagers chose to make rubygems install gems under /usr/local so that
installed gems won’t conflict with those installed by the package
which still installs them in /usr/lib/ruby/gems.
According to the changelog, this should happen with both ruby 1.8 and
way they accomplished this was to provide a operating_system.rb file
installed in the site_ruby/rubygems/default directory for both ruby 1.8
ruby 1.9. This file redefines some methods in the Gem module so that
return the customized installation paths (for example, Gem.default_dir
changed to return “/usr/local/lib/ruby/gems/1.9.1” rather than
Looking at the ruby and rubygems source code, it seems that providing
operating_system.rb file is the correct way for packagers to customize
installation paths used by rubygems, so I tried to understand why this
work correctly with ruby 1.9.
After a bit of experimentation, I understood what was happening:
everytime ruby 1.9 is launched, it requires some files, including
operating_system.rb. According to the contents of $", the other files
encdb.so and transdb.so (besides a mysterious enumerator.so which is
without its full path and which doesn’t seems to exist anywhere in the
directory). So, the reason rubygems uses the wrong directory is that it
loaded after operating_system.rb, and thus overwrites the methods
there, restoring the original ones.
After this discovery, I tried to understand why ruby loaded
operating_system.rb at startup. Playing a bit with the command line
found out the file wasn’t loaded if I used the --disable-gem switch. So,
ruby19 --disable-gem /usr/bin/gem19 environment
produced the correct results. I tried looking at the ruby source code to
what was the exact effect of calling --disable-gem, but I’m not skilled
in C to understand ruby initialization code. I also tried looking for
references to operating_system.rb in the source code (outside the
directory) but the only place I found it mentioned is in gem_prelude.rb
isn’t installed on my system.
With ruby 1.8, this issue doesn’t happen because operating_system.rb
loaded by ruby at startup, but only after other rubygems file, so the
it defines aren’t overwritten.
After this long explaination (I’m sorry for this, but I wanted to make
situation clear), here are my questions:
- is there someone else using ruby 1.9.2 (or maybe even 1.9.1, I’m not
whether this issue also happened with ruby 1.9.1 or not) on Gentoo which
reproduce this issue? If so, I’ll post a bug on the gentoo bugtraker
if you’re using gentoo and ruby 1.9.2 and not seeing this problem, do
so I’ll know the problem I’m facing is related to my system’s
- does anyone know (or has any clue on) why ruby loads certain files at
Thanks in advance