[Rubygems-developers] Any experiences managing gems without root access?

Jim Weirich jim.weirich at gmail.com
Mon Aug 20 09:06:06 EDT 2007

On Aug 20, 2007, at 6:16 AM, Chad Woolley wrote:

> On 7/25/07, Ryan Davis <ryand-ruby at zenspider.com> wrote:
>> I don't think that is right. GEM_HOME seems to be ... sketchy. I
>> think you want GEM_PATH and to use the -i flag on 'gem install'... I
>> got it working once and have a transcript with Jim where I worked it
>> out. I plan on writing it up because it'll really help consultants.
> OK, this is stumping me.  I'd like to use a non-root user, without
> using sudo, to be able to
> 1. setup/install the rubygems dist from scratch to an alternate
> location for which the user has write access
> 2. install/uninstall gems from that location
> 3. tell rubygems at application runtime to only use gems from that
> location (only stick stuff gems from there on my load path)
> Should that all be possible?  If not, is any subset possible?  Any
> detailed commands would be great...

I made a wonderful little screen cast, and then discovered my server  
is down so I have nowhere to upload it to.

So, you get the low tech version:

# Create a repository
mkdir repository

# Install the sources gem.  The sources gem has to be in
# at least one of your repositories.  Since you want to make this
# be the one an only one, there you go.
# Oh, this assumes you have a rubygems repository already installed
# in the more-or-less normal place.
gem install -i repository `gem env gemdir`/cache/sources-0.0.1.gem

# Now make this new repository the one that RubyGems will use.
export GEM_HOME=$PWD/repository

# Now you can install gems into it.
gem install rake

# The first install always seems to fail.  Sigh.  Someone should fix  
# Try again:
gem install rake
gem install flexmock

# List your local gems, should list only sources, rake and flexmock:
gem list -l

# Try using the gems:
require 'rubygems'
require 'rake'      # should work
require 'builder'   # should not work

# and there you go!

-- Jim Weirich
-- jim.weirich at gmail.com

More information about the Rubygems-developers mailing list