tag:help.rubygems.org,2010-01-19:/discussions/questions/148-strange-gem-path-searching-for-native-extensionsRubyGems.org: Discussion 2012-07-06T00:52:45Ztag:help.rubygems.org,2010-01-19:Comment/170269532012-07-02T06:53:45Z2012-07-02T06:53:45ZStrange gem path searching for native extensions<div><p>Since a few weeks I'm hunting down a strange issue with
<em>bundler</em> and <em>nokogiri</em>. This issue is highly
related to my question and may serve as a solid background
information. You may look up the <a href=
"https://github.com/carlhuda/bundler/issues/1987">bundler issue on
github</a>.</p>
<p>The essential problem of abovementioned issue is the
<code>$LOAD_PATH</code>. A call to <code>require
'bundler/setup'</code> modifies the <code>$LOAD_PATH</code> 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:</p>
<pre>
<code>/usr/share/gems/gems/nokogiri-1.5.4/lib
/usr/lib/gems/exts/nokogiri-1.5.4/lib</code>
</pre>
<p>While a "normal" <code>require 'nokogiri'</code> via
<em>irb</em> is able to resolve both paths and add them to
<code>$LOAD_PATH</code>, the bundler code does not find the
<code>/usr/lib/gems/exts/*</code> path where the native extensions
reside. You may have a look at <a href=
"https://gist.github.com/2940316">this gist</a> for details.</p>
<p>During analysis I learned that rubygems is overriding ruby's
standard <code>require</code> command with its own implementation
in order to be able to fully resolve gems during the require call.
Me as well as maintainers of <em>bundler</em> are not sure how
<em>rubygems</em> actually is able to resolve the "far placed"
<code>exts</code> folder. The core maintainer would adapt the path
resolvement strategy in bundler to that from rubygems in order to
overcome the initial issue.</p>
<p>My questions with regard to the above case:</p>
<ul>
<li>How does <em>rubygems</em> resolve the paths and where can I
find (and read) the corresponding code?</li>
<li>Is the <code>/usr/lib/gems/exts/*</code> location a usual or
valid place? How come <em>rubygems</em> places native extensions
there?</li>
</ul>
<p>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.</p>
<p>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.</p>
<p>Thanks for your support!</p></div>amc68ktag:help.rubygems.org,2010-01-19:Comment/170269532012-07-05T19:37:08Z2012-07-05T19:37:08ZStrange gem path searching for native extensions<div><p>RubyGems did not create <code>/usr/lib/gems/exts</code>. 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.</p>
<p>Please add the output of <code>gem env</code></p>
<p>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.</p></div>Eric Hodeltag:help.rubygems.org,2010-01-19:Comment/170269532012-07-05T23:47:48Z2012-07-05T23:47:49ZStrange gem path searching for native extensions<div><p>Fedora's rubygems package separates compiled extensions from the
Ruby source-code. You will need to install Fedora's
<code>rubygem-bundler</code> package which supports these separate
paths.</p></div>postmodern.mod3tag:help.rubygems.org,2010-01-19:Comment/170269532012-07-06T00:52:44Z2012-07-06T00:52:44ZStrange gem path searching for native extensions<div><p>In that case I will close this discussion.</p></div>Eric Hodel