[Rubygems-developers] [ rubygems-Bugs-28726 ] gem install --user-install as root adds cached .gem file outside of HOME

noreply at rubyforge.org noreply at rubyforge.org
Tue Nov 16 15:43:27 EST 2010


Bugs item #28726, was opened at 2010-11-16 12:43
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=28726&group_id=126

Category: None
Group: None
Status: Open
Resolution: None
Priority: 3
Submitted By: Jeremy Evans (jeremyevans)
Assigned to: Nobody (None)
Summary: gem install --user-install as root adds cached .gem file outside of HOME

Initial Comment:
I think the problem is at https://github.com/rubygems/rubygems/blob/master/lib/rubygems/remote_fetcher.rb#L80

Basically, in RemoteFetcher#download, it's checking whether the install_dir (Gem.dir by default) is writable, and if so, it uses that dir.  However, if the user is using the --user-install option, even if the user is root, it should not be writing outside of HOME/.gem.  Basically, if the --user-install option is given, it should always download to HOME/.gem.  This may require an API change.

This affects building OpenBSD ports for some gems, since the --user-install option is used (in combination with a fake HOME).  Usually, building is done as a regular user and is fine.  However, if the builder is root, rubygems adds the .gem files to the /usr/local/lib/ruby directory when the gem is installed to HOME/.gem.  Then when the package builder goes to install the package, the cached .gem file already exists and the package install fails.

This isn't a critical bug, as it can be trivially worked around by specifying GEM_HOME=$HOME/.gem in the environment when using gem install --user-install (which the OpenBSD ports system now does).

----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=575&aid=28726&group_id=126


More information about the Rubygems-developers mailing list