Best practices for managing gem_home/gem_path on OSX to coexist with MRI?

What is the best way to manage gems on a box (OSX Leopard) that will
run both MRI and JRuby? Do you install JRuby gems separately under
JRuby’s gem home? How do people manage your GEM_HOME and GEM_PATH?
Do you manage them to only include the JRuby gem home? Do you use
~/.gemrc? Symlinks? Wrapper scripts? Something else? Links to good
docs or articles are welcome…

My first attempt was to put JRuby’s home as gem_home in ~/.gemrc just
for trying out Rails under JRuby. This failed badly though - OSX puts
the (very outdated) system gems on the GEM_PATH, which meant I picked
up fastthread 1.0.1, which caused the Rails server startup hung in an
endless loop with no mention of fastthread in debug output (jruby irc
kindly helped me debug with dtrace). To avoid problems like that in
the future, I want to only use MRI gem home with MRI, and only JRuby
gem home with JRuby, and ideally have both working at the same time
and not have to manually switch anything. Possible?

Thanks,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Wed, Sep 16, 2009 at 10:28 PM, Chad W. [email protected]
wrote:

What is the best way to manage gems on a box (OSX Leopard) that will
run both MRI and JRuby? Do you install JRuby gems separately under
JRuby’s gem home?

Yes, absolutely.

How do people manage your GEM_HOME and GEM_PATH?

There’s no need to worry about that at all. Whichever executable
you’re using will use the appropriate gems.

At least that’s my experience on both OS X and *nix.


Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 17, 2009 at 9:23 AM, Chad W. [email protected]
wrote:

Unfortunately, that doesn’t seem to be the case. Please see my
example in the original post.

You mean this?

My first attempt was to put JRuby’s home as gem_home in ~/.gemrc just

That’s your problem – you don’t need to do anything.

I have JRuby installed as ‘/usr/local/jruby-1.3.1’, and added to my
PATH in .bashrc.local

To install gems I just type, e.g. sudo jruby -S gem install foo

That’s it. No configuration necessary. And my MRI installation works
just fine with sudo gem install foo.


Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I’m using MacPorts to install JRuby. I haven’t had any collisions
between
JRuby’s gems and Ruby 1.8’s, or Ruby 1.9’s. Perhaps you should
considering
installing via MacPorts or at least examining how they install JRuby?
James

On Thu, Sep 17, 2009 at 5:15 AM, Hassan S.
[email protected] wrote:

There’s no need to worry about that at all. Whichever executable
you’re using will use the appropriate gems.

At least that’s my experience on both OS X and *nix.

Thanks for the response Hassan…

Unfortunately, that doesn’t seem to be the case. Please see my
example in the original post.

In any case, I’m looking to find out exactly what people do to manage
JRuby and MRI coexisting on OSX.

Thanks,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

hello,

with it it works fine sharing the GEM_PATH,GEM_HOME between jruby and
MRI working with rails. and even unpacking the gems into the rails
works for both.

but looking back at your example where things fails is the fastthread
gem.

so the big question is whether the actual problem is that library ?
maybe I misunderstood something then just forget the last remark.

with regards
Kristian

---------- Forwarded message ----------
From: Hassan S. [email protected]
Date: Thu, Sep 17, 2009 at 10:00 PM
Subject: Re: [jruby-user] Best practices for managing
gem_home/gem_path on OSX to coexist with MRI?
To: [email protected]

On Thu, Sep 17, 2009 at 9:23 AM, Chad W. [email protected]
wrote:

Unfortunately, that doesn’t seem to be the case. Â Please see my
example in the original post.

You mean this?

My first attempt was to put JRuby’s home as gem_home in ~/.gemrc just

That’s your problem – you don’t need to do anything.

I have JRuby installed as ‘/usr/local/jruby-1.3.1’, and added to my
PATH in .bashrc.local

To install gems I just type, e.g. sudo jruby -S gem install foo

That’s it. No configuration necessary. And my MRI installation works
just fine with sudo gem install foo.


Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

  http://xircles.codehaus.org/manage_email


Kristian Meier + Saumya Sharma + Sanuka Meier
Vadakkethu House,
Edayanmula West PO - 689532,
Pathanamthitta District, Kerala, INDIA

tel: +91 468 2319577

protect your privacy while searching the net: www.ixquick.com


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 17, 2009 at 11:22 AM, Chad W. [email protected]
wrote:

That doesn’t seem to be the case. I think my specific problem was
automatically getting the outdated OSX system gems (specifically
fastthread) on the path, which caused the old fastthread to be picked
up until I explicitly installed a new one in JRuby’s home. This shows
the problem:

http://gist.github.com/188626

From your gist:

  • GEM PATHS:
    • /usr/local/lib/jruby-1.3.1/lib/ruby/gems/1.8

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8

I don’t know how it got that way but that’s messed up – you shouldn’t
have the MRI and JRuby gem directories mixed together.

ripple:~$ jruby -S gem env
RubyGems Environment:

  • GEM PATHS:
    • /usr/local/jruby-1.3.1/lib/ruby/gems/1.8
    • /Users/hassan/.gem/jruby/1.8

:: so no overlap with MRI. So, somewhere on your system, there has
to be a configuration file that’s causing this “hey, you’ve got MRI in
my JRuby” situation. Good luck finding it!


Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 17, 2009 at 11:47 AM, Hassan S.
[email protected] wrote:

:: so no overlap with MRI. So, somewhere on your system, there has
to be a configuration file that’s causing this “hey, you’ve got MRI in
my JRuby” situation. Good luck finding it!

Hassan, do you have MRI installed from source or macports, or are you
using the Leopard default install? If you are not using the default
Leopard Ruby, that is the difference.

I think it is RubyGems itself which puts the Leopard system gems on
the GEM_PATH. See Gem.default_dir in defaults.rb of RubyGems itself:

http://github.com/vvs/rubygems/blob/master/lib/rubygems/defaults.rb#L20

So, this problem may be specific to OSX users using the default
Leopard Ruby install, but I’d still like to know how to properly
manage it given that environment.

Thanks,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 17, 2009 at 9:30 AM, Hassan S.
[email protected] wrote:

That’s it. No configuration necessary. And my MRI installation works
just fine with sudo gem install foo.

That doesn’t seem to be the case. I think my specific problem was
automatically getting the outdated OSX system gems (specifically
fastthread) on the path, which caused the old fastthread to be picked
up until I explicitly installed a new one in JRuby’s home. This shows
the problem:

http://gist.github.com/188626

I could try to address this by managing my GEM_HOME env variable
explicitly, as suggested here:

http://blog.zenspider.com/2009/08/gem-path-rubygems-and-you.html

However, that trick doesn’t seem to work unless I explicitly have my
gem_home set in ~/.gemrc:

$ gem env home
/Library/Ruby/Gems/1.8
$ jruby -S gem env home
/Library/Ruby/Gems/1.8
$ mv ~/.gemrc.bak ~/.gemrc
$ cat ~/.gemrc
gemhome: /usr/local/lib/jruby-1.3.1/lib/ruby/gems/1.8/

$ jruby -S gem env home
/usr/local/lib/jruby-1.3.1/lib/ruby/gems/1.8/

…which puts me back in the same boat of having to manually switch my
gem_home in ~/.gemrc when I switch between MRI and JRuby…

Thanks for the help,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

On Thu, Sep 17, 2009 at 2:23 PM, Chad W. [email protected]
wrote:

Hassan, do you have MRI installed from source or macports, or are you
using the Leopard default install?

I’m 99% sure I’ve never installed Ruby from source on this machine:
Ruby:
Version: 1.8.6
Last Modified: 12/18/07 8:18 AM
Get Info String: Ruby Runtime and Library
Location: /System/Library/Frameworks/Ruby.framework
Private: No

ripple:/System/Library/Frameworks/Ruby.framework/Versions/Current/usr$
./bin/ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]
ripple:/System/Library/Frameworks/Ruby.framework/Versions/Current/usr$
which ruby
/usr/bin/ruby
ripple:/System/Library/Frameworks/Ruby.framework/Versions/Current/usr$
ruby -v
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

:: and I don’t use macports at all.

I think it is RubyGems itself which puts the Leopard system gems on
the GEM_PATH. See Gem.default_dir in defaults.rb of RubyGems itself:

But there would not seem to be any inherent way for one version of
Ruby to know about another and “blend” their gem paths that way.

So, this problem may be specific to OSX users using the default
Leopard Ruby install, but I’d still like to know how to properly
manage it given that environment.

I’d like someone else with a similar environment to chime in here with
some more evidence one way or another :slight_smile:


Hassan S. ------------------------ [email protected]
twitter: @hassan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Hi,

I have multiple versions of MRI, JRuby, Rubinius and YARV installed.
All of which I compile and manually maintain myself (I have wrote a
few scripts that pull down the software, untar, compile, install, etc).

I do not place any of these Ruby installations on the path myself, but
rather use a series of aliases to locate them.

For example:

alias jruby=’~/ruby/jruby1.3.1/bin/jruby’
alias j=’~/ruby/jruby1.3.1/bin/jruby -S’

I used to specifically name jgem, etc, but changed to use the ‘j’
alias based on a previous post.

I have however recently been reading on the blogs about the ‘Ruby
Version Manager’ project, which maintains multiple versions of Ruby
for you.

http://rvm.beginrescueend.com/

I have not tried this myself yet, but I have seen plenty of positive
tweets recently and was thinking about giving it a go.

Regards
Matthew W.

On 18/09/2009, at 7:23 AM, Chad W. wrote:

- /usr/local/jruby-1.3.1/lib/ruby/gems/1.8

Thanks,
– Chad


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

I’ll give rvm a +1. Works great for me. It doesn’t let you share
gems between instances though.

On Sep 17, 2009, at 5:57 PM, Matthew W. wrote:

For example:

  • /usr/local/jruby-1.3.1/lib/ruby/gems/1.8

– Chad
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs