tag:help.rubygems.org,2010-01-19:/discussions/problems/5-default-gem_path-and-gem_homeRubyGems.org: Discussion 2011-04-07T20:59:24Ztag:help.rubygems.org,2010-01-19:Comment/9081052010-01-25T17:57:13Z2010-03-30T14:51:21ZDefault $GEM_PATH and $GEM_HOME<div><p>Yeah...</p>
<p>Should:</p>
<p>a) have some compiled-in option to specify a default
GEM_PATH<br>
b) do what <code>irb</code> and <code>gem</code> bin scripts do -
check if a) exists and then just add those 3 extra lines to the top
of each bin script (improve the bin scripts template).</p></div>dreamcat4tag:help.rubygems.org,2010-01-19:Comment/9081052010-01-25T19:06:55Z2010-01-25T19:06:55ZDefault $GEM_PATH and $GEM_HOME<div><p>It looks like you're running rvm. If you don't use rvm
everything works just fine. There's no need to set GEM_HOME or
GEM_PATH by default.</p></div>Eric Hodeltag:help.rubygems.org,2010-01-19:Comment/9081052010-01-25T22:12:38Z2010-03-30T14:51:21ZDefault $GEM_PATH and $GEM_HOME<div><p>Hi,</p>
<p>Well you are right in the sense that we can make a symlink into
the ruby installation.</p>
<pre>
<code># Like this:
ln -sf /opt/rvm/gems/ree-1.8.7-2010.01 /opt/rvm/rubies/ree-1.8.7-2010.01/lib/ruby/gems/1.8</code>
</pre>
<p>Actually I'm pretty miffed why this issue is marked as
"Resolved" so quickly. Because its rather 'assuming too much' to
expect all future rubies to adhere to this MRI site directory
structure. Its brittle and will break easily. As shown with rvm. So
I am suggesting we could re-think the following method:</p>
<pre>
<code>def self.default_dir
if defined? RUBY_FRAMEWORK_VERSION then
File.join File.dirname(ConfigMap[:sitedir]), 'Gems',
ConfigMap[:ruby_version]
# 1.9.2dev reverted to 1.8 style path
elsif RUBY_VERSION > '1.9' and RUBY_VERSION < '1.9.2' then
File.join(ConfigMap[:libdir], ConfigMap[:ruby_install_name], 'gems',
ConfigMap[:ruby_version])
else
File.join(ConfigMap[:libdir], ruby_engine, 'gems',
ConfigMap[:ruby_version])
end
end</code>
</pre>
<p>And provide some clearly exposed API / way to set the default
path here. Even if its just something statically defined in a file.
I can we get it from <code>ConfigMap[:sitedir]</code>. Well we
maybe could introduce a new variable
<code>ConfigMap[:gemsdir]</code> then:</p>
<pre>
<code>ConfigMap[:gemsdir] ||= ConfigMap[:sitedir]</code>
</pre>
<p>This is the better solution here.</p></div>dreamcat4tag:help.rubygems.org,2010-01-19:Comment/9081052010-01-25T22:28:38Z2010-01-25T22:28:38ZDefault $GEM_PATH and $GEM_HOME<div><p>RubyGems pulls the information needed to work from rbconfig.rb
for the ruby that is executing whichever gem-installed executable
you're using. There is no need to set GEM_HOME or GEM_PATH to any
defaults as those are determined directly from rbconfig.rb.</p>
<p>If rvm is breaks when using RubyGems then rvm has a bug, not
RubyGems.</p>
<p>If rvm isn't installing gems in the correct place then it needs
to set GEM_HOME and GEM_PATH for you, or provide a defaults
override as described under the heading "RubyGems Defaults,
Packaging" for <code>ri Gem</code>.</p></div>Eric Hodel