# One gem to rule them all?

**URL:** <https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129>\
**Category:** IronRuby\
**Created:** [January 6, 2010, 12:38am UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129 "2010-01-06T00:38:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 6, 2010, 12:38am UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129/1 "2010-01-06T00:38:38Z")

</div>

Hi guys,

On my MacBook I’m noticing I’m having to install a gem three times  
(MRI, IronRuby, JRuby) - which is getting really annoying 🙂

Am I doing something wrong??? Is there a way around this??

Thanks

Ben

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 6, 2010, 12:43am UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129/2 "2010-01-06T00:43:19Z")

</div>

What gem?

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 6, 2010, 12:52am UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129/3 "2010-01-06T00:52:41Z")

</div>

you can share gems by setting a location in .gemrc  
But there be dragons. because gem install will only generate the proper  
executable links for the version that is installing the gem.

if you don’t want to download the gems all the time then you can just  
reuse  
the .gem file from

Assuming you have ruby installed in /usr

/usr/lib/ruby/gems/1.9.1/cache

if you share a location you can use gem pristine gem\_name to (re)install  
the  
gem in the other ruby version.

for libraries that don’t have any executables or native extensions that  
should work just fine. the core of the gems functionality is to add the  
paths /usr/lib/ruby/gems/1.9.1/gems/\*/lib to the load path.

The install process also copies the files from the gem/bin folder to  
/usr/lib/ruby/gems/1.9.1/bin and then to /usr/bin

If you use homebrew then this stuff is hidden a little bit deeper  
because  
homebrew symlinks the lib,bin,var,… folers from within a Cellar  
repository.

So in short you should be able to do so but sometimes it might require a  
little bit of work to make it dance.

## [http://blogs.sun.com/mandy/entry/rubygems\_etc\_gemrc](http://blogs.sun.com/mandy/entry/rubygems_etc_gemrc)

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Google Wave: removed\_email\_address@domain.invalid  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 6, 2010, 4:25pm UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129/4 "2010-01-06T16:25:05Z")

</div>

Hey Ben,

This is a problem, but one that you’re better of living with. I’ve tried  
sharing gem homes in the past and it can get real messy right after you  
install your first native gem, of if you have bin scripts like Ivan  
pointed out.

Perhaps you could create a wrapper shell script that invokes a gem  
install for each flavour of Ruby you have?

Cheers,  
Sidu.

> **[Electric Sheep Blog](http://blog.sidu.in)**
>
> On hacking and startups by Sidu Ponnappa

[http://twitter.com/ponnappa](http://twitter.com/ponnappa)

---

<div class="post-metadata">

**Author:** ![benhiller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8e7dd6/32.png) [@benhiller](https://www.ruby-forum.com/u/benhiller)\
**Post date:** [January 6, 2010, 12:56am UTC](https://www.ruby-forum.com/t/one-gem-to-rule-them-all/181129/5 "2010-01-06T00:56:12Z")

</div>

Ben, do you mean each implementation is using a different RubyGems  
repository, so running “gem list” on each implementation gives you a  
different list? To work-around this, set both the “GEM\_PATH” and  
“GEM\_HOME” environment variables to be the RubyGem repo you want to use,  
and all the implementations will pull gems from only that one.

For example, dev.bat in IronRuby’s source sets GEM\_PATH to be a location  
we have checked in, so Ruby and IronRuby share the same gems. If  
GEM\_HOME was also set, then installing would default to that location.

~js
