hmans / rbfu

Minimal Ruby version management is minimal.
MIT License
118 stars 10 forks source link

How does rbfu handle gems with native extensions? #27

Open jarl-dk opened 11 years ago

jarl-dk commented 11 years ago

Sorry if this is not the right place to ask, but I couldn't find a mailing-list or group forum:

I am considering to switch to rbfu instead of rvm as the need for gemsets are not relevant anymore after Bundler has reached such a mature state and widespread use.

It seems like rbfu is only handling ruby versioning. So how about gems with native extension?

If rbfu is not gem-aware I will guess that a gem install nokogiri will install it in /usr/local/gems or something like that with native extensions built for the active ruby version, say 1.9.2.

But what happens then when working on another project that uses ruby 1.9.3? Will that also use the nokogiri gem (installed in /usr/local/gems and built for ruby 1.9.2). The README is not very clear whether gem installations are shared across ruby versions or not. If gem installations are shared across ruby versions, I smell problems with gems that contains native extensions.

maxmeyer commented 11 years ago

I think the gem command will consider GEM_HOME and GEM_PATH-evironment variables. Please also check if you have defined a /etc/gemrc with --user-install. If you defined the GEM* the user-install-parameter to gem will make trouble. So please clear that file (temporary).

Try that, please

#create a new shell please

# then...
export GEM_HOME="/tmp/lib/ruby/gems" 
export GEM_PATH="/tmp/lib/ruby/gems"

mkdir -p $GEM_HOME # $GEM_PATH
#install nokogiri to /tmp
gem install nokogiri

ls -al  $GEM_HOME/gems/nokogiri*

On my systems that works pretty well.

If you would like to get to know how rbfu does its magic check this. Besides adding the GEM*-env-vars it also adds the gem bin-directory (lib/ruby/gems/bin) to your PATH.

#new shell please

#then...
% env | grep -i "ruby\|gem"
# nothing

#you need    eval "$(rbfu --init)"    in your .bashrc/.zshrc for rbfu-env to be available --> please see README
% rbfu-env @1.9.3-p194
Activated Ruby 1.9.3-p194. (from command line)
% env | grep -i "ruby\|gem"
PATH=/home/user/.rbfu/rubies/1.9.3-p194/bin:/home/user/.rbfu/rubies/1.9.3-p194/lib/ruby/gems/bin
GEM_HOME=/home/xgvndeg/.rbfu/rubies/1.9.3-p194/lib/ruby/gems
GEM_PATH=/home/xgvndeg/.rbfu/rubies/1.9.3-p194/lib/ruby/gems
RBFU_RUBY_VERSION=1.9.3-p194