Created attachment 272249 [details, diff] gemhome.patch Currently, Gentoo sets the rubygems "default_dir" to /usr/local/lib/ruby/gems/1.* which is obviously not writeable by regular users. This is mildly annoying if you want to install some user-specific gems but becomes a real problem when trying to use Bundler or even just Rails 3 in general. Regardless of whether any gems are actually missing, it tries to create the "default_dir" upon startup, failing like so. # rails server /usr/lib64/ruby/1.8/fileutils.rb:243:in `mkdir': Permission denied - /usr/local/lib64/ruby (Errno::EACCES) from /usr/lib64/ruby/1.8/fileutils.rb:243:in `fu_mkdir' from /usr/lib64/ruby/1.8/fileutils.rb:217:in `mkdir_p' from /usr/lib64/ruby/1.8/fileutils.rb:215:in `reverse_each' from /usr/lib64/ruby/1.8/fileutils.rb:215:in `mkdir_p' from /usr/lib64/ruby/1.8/fileutils.rb:201:in `each' from /usr/lib64/ruby/1.8/fileutils.rb:201:in `mkdir_p' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:261:in `configure_gem_home_and_path' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:72:in `configure' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:128:in `definition' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:118:in `load' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler.rb:101:in `setup' from /usr/lib64/ruby/gems/1.8/gems/bundler-1.0.9/lib/bundler/setup.rb:6 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require' from /home/chewi/Projects/SunnySmiles/config/boot.rb:6 from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib64/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require' from script/rails:5 I used to work around this by setting gemhome in ~/.gemrc but now that I have installed Ruby 1.9 as well as 1.8, this is no longer viable as you can only specify one version or the other. There is no variable interpolation in this file. Attached is a patch that only sets "default_dir" to a system-wide location if you are root, otherwise it makes it the same as "user_dir". I have ensured that the system-wide location is still always included in the gempath. Feel free to change the root detection method. I wasn't sure what would be best but I found that ENV['EUID'] was nil for some reason. Bug #336863 needs to be fixed before this will be effective for Ruby 1.9.
Hmm I just tried to install a gem that has an executable script and it complained that I couldn't write to /usr/local/bin. I guess we need to give default_bindir the same treatment but I'm not sure whether it should be ~/bin, ~/.gem/bin or ~/.gem/ruby/1.*/bin. It'll probably have to be the latter or the different versions will clash. But this is also true of /usr/local/bin. Maybe that location needs to be changed too?
Hmm and now I'm thinking about the scripts Portage installs. I notice these are currently all pointing to /usr/bin/ruby18. Is that because I have 1.8 selected with eselect? I'm having to explicitly do "ruby19 /usr/bin/rake" when I want to use 1.9 at the moment. Maybe we should also install these to different locations and adjust the PATH based on the eselect choice? Is that possible?
What we would like to see is: - gentoo packages install in /usr/lib - sudo gem install (or similar) installs in /usr/local/lib - gem install installs in ~/.gems I think we should focus on getting to this situation with newer versions of rubygems, given that we are a couple of versions behind.
Well, that is exactly what this patch does. :) I'll see if I can make the changes I proposed for the bindir as well.
The check for root would need to be changed. I'm sure we have paranoid users around that name the account differently. We should probably check Process.euid instead. @Alex: can you check this patch, since you know most about our rubygems modifications?
(In reply to comment #5) > The check for root would need to be changed. I'm sure we have paranoid users > around that name the account differently. We should probably check Process.euid > instead. > > @Alex: can you check this patch, since you know most about our rubygems > modifications? I agree with the general idea of the patch, but not with the actual implementation. root does not have to be called root, all that matters is UID==0.
(In reply to comment #6) > (In reply to comment #5) > > The check for root would need to be changed. I'm sure we have paranoid users > > around that name the account differently. We should probably check Process.euid > > instead. > > > > @Alex: can you check this patch, since you know most about our rubygems > > modifications? > > I agree with the general idea of the patch, but not with the actual > implementation. root does not have to be called root, all that matters is > UID==0. which is basically what Hans said.. It's too late. Anyway, that root thing needs changing
Fixed in rubygems-1.3.7-r5, using Process.euid.
I was still intending to post up my bindir ideas here but I guess I'll save that for a separate bug report. Thanks for putting this through.