Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing gems to which Ruby with rbenv

How does one control which Ruby a gem is installed to using rbenv? Or could there be a central place accessible to all Rubies? I am just running Ruby scripts not Rails. rbenv-gemset seems to be for that?

like image 854
Greg Avatar asked Jul 10 '13 04:07

Greg


People also ask

Does Rbenv install Ruby?

Rbenv is a command line tool that lets you switch between installed versions of Ruby. It can also install new versions of Ruby using the ruby-build plugin.

Where is Ruby installed with Rbenv?

One of those is the ruby-build project, which also provides an optional plugin for Rbenv that provides an rbenv install subcommand. This plugin will typically install Ruby implementations in ~/. rbenv/versions/* , but that is configurable.

How do I install a specific version of a ruby gem?

Use `gem install -v` You may already be familiar with gem install , but if you add the -v flag, you can specify the version of the gem to install. Using -v you can specify an exact version or use version comparators.


2 Answers

The gem is installed into whatever your currently selected Ruby is. E.g.

rbenv shell 2.0.0-p247
gem install bundler  # bundler is installed for Ruby 2.0.0-p247 only
rbenv shell 1.9.3-p447
gem install bundler  # bundler is installed for Ruby 1.9.3-p447 only
like image 149
Andrew Marshall Avatar answered Oct 09 '22 02:10

Andrew Marshall


Just to add on: rbenv-gemset would be for organizing your gems within the same ruby version. Only rbenv controls which ruby you install your gems to...

like image 41
Jeffrey 'jf' Lim Avatar answered Oct 09 '22 02:10

Jeffrey 'jf' Lim