Default installation prefix should be /usr/local on UNIX-like platforms
When RubyGems is installed using its defaults, it is partially
in /usr and partially in /usr/local.
Specifically:
# ruby setup.rb
$ which gem1.8
/usr/bin/gem1.8
$ ls -l /usr/local/lib/site_ruby/1.8/
total 52
-rw-r--r-- 1 root root 1415 2010-12-10 15:13 gauntlet_rubygems.rb
drwxrwsr-x 2 root staff 4096 2010-07-24 01:15 i486-linux
drwxr-xr-x 2 root root 4096 2010-12-10 15:13 rbconfig
drwxr-xr-x 5 root root 4096 2010-12-10 15:13 rubygems
-rw-r--r-- 1 root root 29400 2010-12-10 15:13 rubygems.rb
-rw-r--r-- 1 root root 268 2010-12-10 15:13 ubygems.rb
$
This appears to be by design, since the default installation location is taken from the Ruby program that is installing RubyGems:
$ ruby -rrbconfig -e'puts RbConfig::CONFIG["bindir"]'
/usr/bin
$
The --bindir used by RubyGems need not match that
of Ruby itself, since RubyGems writes its programs with the full
path to Ruby:
$ head -n1 $(which gem1.8)
#!/usr/bin/ruby1.8
$
I believe the most correct default behavior is to behave as if
--prefix=/usr/local. However, this doesn't quite work
right:
# ruby setup.rb --prefix=/usr/local
...
$ which gem1.8
/usr/local/bin/gem1.8
$ gem1.8 list
/usr/local/bin/gem1.8:8:in `require': no such file to load -- rubygems (LoadError)
from /usr/local/bin/gem1.8:8
$ ls -l /usr/local/lib/
total 332
-rw-r--r-- 1 root root 1415 2010-12-10 15:20 gauntlet_rubygems.rb
-rw-r--r-- 3 root root 272564 2010-12-08 16:37 libcurl.a
-rwxr-xr-x 3 root root 904 2010-12-08 16:37 libcurl.la
drwxr-xr-x 2 root root 4096 2010-12-08 16:37 pkgconfig
drwxrwsr-x 4 root staff 4096 2010-07-24 00:59 python2.6
drwxr-xr-x 2 root root 4096 2010-12-10 15:20 rbconfig
drwxr-xr-x 5 root root 4096 2010-12-10 15:20 rubygems
-rw-r--r-- 1 root root 29400 2010-12-10 15:20 rubygems.rb
drwxr-xr-x 3 root root 4096 2010-07-24 01:15 site_ruby
-rw-r--r-- 1 root root 268 2010-12-10 15:20 ubygems.rb
$
Trying to work around the issue proved futile:
# ruby setup.rb --bindir=/usr/local/bin
ERROR: While executing gem ... (OptionParser::InvalidOption)
invalid option: --bindir=/usr/local/bin
# ruby setup.rb --prefix=/usr/local/lib/site_ruby/1.8
...
$ which gem1.8
$ ls -l /usr/local/lib/site_ruby/1.8/
total 12
drwxr-xr-x 2 root root 4096 2010-12-10 15:27 bin
drwxrwsr-x 2 root staff 4096 2010-07-24 01:15 i486-linux
drwxr-xr-x 4 root root 4096 2010-12-10 15:27 lib
$
All of this is to say:
- Could you please fix
--prefixto work properly? - Could you please make the default as is customary for source packages?
Comments are currently closed for this discussion. You can start a new one.
2 Posted by Richard Crowley on 11 Dec, 2010 12:23 AM
That last line should read:
/usr/localas is customary for source packages?Support Staff 3 Posted by Eric Hodel on 11 Dec, 2010 01:19 AM
RubyGems' installer is working as designed and desired.
RubyGems defaults to the paths that match your Ruby installation from rbconfig.rb. It appears that your ruby is partially installed in /usr and partially installed in /usr/local. RubyGems matches this so everything will Just Work™. RubyGems depends heavily upon the values set in rbconfig.rb at ruby compile time to locate installed gems and executables in order to behave correctly and remain properly self-contained when faced with multiple ruby versions.
To be more specific,
gemis installed next to therubythat was used to install it. This way the that comes first in PATH will be able to load gems installed by the that comes first in PATH, and any executable scripts installed by RubyGems will use the correct installed gems.The --prefix option is for users who wish to install multiple copies of RubyGems. It behaves like autoconf's --prefix option for configure scripts. Usually this means that RubyGems will not Just Work™ when installed using --prefix without some extra configuration and care by the user.
If /usr/local were the customary location for installation RubyGems would not work out of the box as not every OS package of Ruby works with Ruby's preferred install path of /usr/local. By using the values in rbconfig.rb I can be assured that RubyGems will work correctly on your platform.
If you wish to have be installed to /usr/local I suggest you contact your Ruby packager and have them install in your preferred path as well.
Eric Hodel closed this discussion on 11 Dec, 2010 01:19 AM.
Richard Crowley re-opened this discussion on 11 Dec, 2010 09:52 AM
4 Posted by Richard Crowley on 11 Dec, 2010 09:52 AM
(I'm skipping backticks this time because of a bug in Tender.)
The least surprising thing to do by default is install in /usr/local on UNIX-like operating systems. PATH is a user-directed adventure for which your package can't be held liable. "/usr/local/bin/gem1.8" is not surprising.
You're technically correct (the best kind of correct) that --prefix works exactly like it does in an autoconf-enabled package. The problem is, RubyGems is meaningless when installed in autoconf-like directories. RubyGems wants to be installed on Ruby's $:, which usually includes /usr/local/lib/site_ruby and /usr/lib/vendor_ruby but not /usr/local/lib. It's perfectly OK to throw loud errors if you can't find a directory that's both on $: and within the prefix.
You're fucking over people who understand why UNIX is the way it is and care that it is so by mixing /usr and /usr/local. Please stop.
Support Staff 5 Posted by Eric Hodel on 12 Dec, 2010 12:02 AM
To clarify, --prefix installs into autoconf-like directories such that ruby -I can use them easily.
The current behavior is considered correct and will not be changed.
Eric Hodel closed this discussion on 12 Dec, 2010 12:02 AM.