# How to change default gems repository on Debian

**URL:** <https://www.ruby-forum.com/t/how-to-change-default-gems-repository-on-debian/144909>\
**Category:** Ruby\
**Created:** [August 4, 2008, 9:10am UTC](https://www.ruby-forum.com/t/how-to-change-default-gems-repository-on-debian/144909 "2008-08-04T09:10:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![tekhne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@tekhne](https://www.ruby-forum.com/u/tekhne)\
**Post date:** [August 4, 2008, 9:10am UTC](https://www.ruby-forum.com/t/how-to-change-default-gems-repository-on-debian/144909/1 "2008-08-04T09:10:38Z")

</div>

Hi all,

I’m trying to upgrade an old gem installation (0.9.5) on Debian machine.  
On Debian, the default gem repository is /var/lib/gems/1.8. However, if  
I install gem from source, the default location of the repository would  
be /usr/lib/ruby/gems/1.8/. I can export GEM\_HOME variable to change the  
location however, this will not work for crontab scripts which bypass  
.bash\_profile and /etc/profile. There are many crontab scripts setup by  
our users and it’s quite hard to force everyone to change their scripts.  
Therefore, I need to make sure that the default gem repository is  
/var/lib/gems/1.8. How do I force gem installation to do this instead of  
using /usr/lib/ruby/gems/1.8?

Thanks.

---

<div class="post-metadata">

**Author:** ![tekhne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@tekhne](https://www.ruby-forum.com/u/tekhne)\
**Post date:** [August 4, 2008, 9:20am UTC](https://www.ruby-forum.com/t/how-to-change-default-gems-repository-on-debian/144909/2 "2008-08-04T09:20:58Z")

</div>

On Monday 04 August 2008 02:09:18 Peter Hoang wrote:

> I can export GEM\_HOME variable to change the  
> location however, this will not work for crontab scripts which bypass  
> .bash\_profile and /etc/profile.

It might be worth trying .bashrc – .bash\_profile is specifically for  
interactive logins – but that won’t work if they’re using /bin/sh.

Another possibility is /etc/environment, though I remember that not  
working…

Worst case, there’s always setting the environment variable directly  
in /etc/crontab.

There’s also tricks like symlinks, bind-mounts, etc.

I’m sure Rubygems can be installed wherever you like – but you really  
should  
solve the problem of being able to set global environment variables.

---

<div class="post-metadata">

**Author:** ![tekhne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/90ced4/32.png) [@tekhne](https://www.ruby-forum.com/u/tekhne)\
**Post date:** [August 4, 2008, 10:11am UTC](https://www.ruby-forum.com/t/how-to-change-default-gems-repository-on-debian/144909/3 "2008-08-04T10:11:36Z")

</div>

David,

Thanks for the reply. I’ll try .bashrc first to see if it works. I still  
want to know how to set gem repository. Any ideas?
