Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 366153 - dev-ruby/rubygems: default_dir needs to be writeable by user for Bundler
Summary: dev-ruby/rubygems: default_dir needs to be writeable by user for Bundler
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Gentoo Ruby Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-05-05 23:20 UTC by James Le Cuirot
Modified: 2011-05-13 22:03 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments
gemhome.patch (gemhome.patch,752 bytes, patch)
2011-05-05 23:20 UTC, James Le Cuirot
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description James Le Cuirot gentoo-dev 2011-05-05 23:20:21 UTC
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.
Comment 1 James Le Cuirot gentoo-dev 2011-05-06 10:59:14 UTC
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?
Comment 2 James Le Cuirot gentoo-dev 2011-05-06 11:01:45 UTC
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?
Comment 3 Hans de Graaff gentoo-dev Security 2011-05-07 08:47:08 UTC
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.
Comment 4 James Le Cuirot gentoo-dev 2011-05-07 09:01:30 UTC
Well, that is exactly what this patch does. :) I'll see if I can make the changes I proposed for the bindir as well.
Comment 5 Hans de Graaff gentoo-dev Security 2011-05-08 06:43:37 UTC
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?
Comment 6 Alex Legler (RETIRED) archtester gentoo-dev Security 2011-05-08 22:02:23 UTC
(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.
Comment 7 Alex Legler (RETIRED) archtester gentoo-dev Security 2011-05-08 22:02:51 UTC
(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
Comment 8 Hans de Graaff gentoo-dev Security 2011-05-13 17:49:55 UTC
Fixed in rubygems-1.3.7-r5, using Process.euid.
Comment 9 James Le Cuirot gentoo-dev 2011-05-13 22:03:55 UTC
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.