Strange gem path searching for native extensions

amc68k's Avatar

amc68k

02 Jul, 2012 06:53 AM

Since a few weeks I'm hunting down a strange issue with bundler and nokogiri. This issue is highly related to my question and may serve as a solid background information. You may look up the bundler issue on github.

The essential problem of abovementioned issue is the $LOAD_PATH. A call to require 'bundler/setup' modifies the $LOAD_PATH to support the gems within the bundle. However, it does not recognize paths being "far" from the gem hierarchy. In my case, the nokogiri gem is located at the following paths:

/usr/share/gems/gems/nokogiri-1.5.4/lib
/usr/lib/gems/exts/nokogiri-1.5.4/lib

While a "normal" require 'nokogiri' via irb is able to resolve both paths and add them to $LOAD_PATH, the bundler code does not find the /usr/lib/gems/exts/* path where the native extensions reside. You may have a look at this gist for details.

During analysis I learned that rubygems is overriding ruby's standard require command with its own implementation in order to be able to fully resolve gems during the require call. Me as well as maintainers of bundler are not sure how rubygems actually is able to resolve the "far placed" exts folder. The core maintainer would adapt the path resolvement strategy in bundler to that from rubygems in order to overcome the initial issue.

My questions with regard to the above case:

  • How does rubygems resolve the paths and where can I find (and read) the corresponding code?
  • Is the /usr/lib/gems/exts/* location a usual or valid place? How come rubygems places native extensions there?

Finally, I want you to notice that I'm quite new in the ruby || gems || bundler land and don't have much experience on the ruby platform yet. If my description is not complete or does miss established concepts, please bear with me.

I'd appreciate any help, suggestions or directions regarding this issue. I'm willing to locate and fix the issue, but my expertise on both rubygems and bundler is far away from enabling me to do so.

Thanks for your support!

  1. Support Staff 1 Posted by Eric Hodel on 05 Jul, 2012 07:37 PM

    Eric Hodel's Avatar

    RubyGems did not create /usr/lib/gems/exts. I'm not sure how you have files in this directory. Additionally, RubyGems only installs gems into the lib directory based off RbConfig, never the share directory.

    Please add the output of gem env

    How did you install Ruby and RubyGems? Was it from a package? You mention Fedora on the bundler issue. If your Ruby and RubyGems are Fedora packages you will need to contact Fedora for support or switch to a non-packaged Ruby and RubyGems.

  2. 2 Posted by postmodern.mod3 on 05 Jul, 2012 11:47 PM

    postmodern.mod3's Avatar

    Fedora's rubygems package separates compiled extensions from the Ruby source-code. You will need to install Fedora's rubygem-bundler package which supports these separate paths.

  3. Support Staff 3 Posted by Eric Hodel on 06 Jul, 2012 12:52 AM

    Eric Hodel's Avatar

    In that case I will close this discussion.

  4. Eric Hodel closed this discussion on 06 Jul, 2012 12:52 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac