[Rubygems-developers] Gem Cache

Colin Fleming colin.mailinglist at gmail.com
Tue Aug 2 19:45:01 EDT 2005

Hi all,

I'm trying to get a slightly odd Gems setup as part of making a
self-contained Rails environment. Specifically, I'd like to control
where the cache goes, but it seems to be impossible. The docs say that
the GEMCACHE env var should be used to specify where the "cache file"
goes if the standard cache file is unwriteable. Is this in fact
supposed to read "cache dir"? If not, what is the cache file?

In any case, if I try making the cache dir unwriteable right after
install I just get an error:

$chmod -w env/lib/ruby/gems/1.8/cache
$gem install rails --include-dependencies
Attempting remote installation of 'rails'
ERROR:  While executing gem ... (Errno::EACCES)
    Permission denied -

and a quick look at the code shows that the path seems to be hard coded:

    def install(gem_name,
        version_requirement = "> 0.0.0",


      cache_dir = File.join(install_dir, "cache")

And looking at the install code, it passes either Gem.dir or the -i
parameter from the command line to install_dir. So it seems to be
impossible to change the cache location independently of the install
location, is this correct?

setup.rb also seems to ignore the --rubypath option (i.e. I can't get
it to change the shebang line). In general getting Gems to do abnormal
things has been very frustrating, and much harder than IMO it should
be. If I get a bit of time and these are really bugs I'll try and
patch them.


More information about the Rubygems-developers mailing list