Frage

I'm trying to follow this exact workflow from within Ruby code:

  1. rvm use 2.0.0@some-name --create
  2. gem install some-gem

I didn't find much documentation about using RVM in Ruby.

Edit: I know these steps are correct from the shell but I would like to run them from within a Ruby script. e.g ruby myscript.rb that would run these two steps.

When placing these two directives within backticks, it doesn't work and the some-gem from the sample above gets installed inside whatever gemset is currently in use.

Edit 2: I want a Ruby script that creates a new RVM gemset and installs a gem inside it (Devise, for example).

War es hilfreich?

Lösung 2

As answered by Michal Papis on Github in this question, it can be done only with hacking a little and using the rvm-with gem:

require "rvm/with"
RVM.with "2.1.0@gemset --create" do |r|
  puts r.execute "gem install ..."
  puts r.execute "bundle exec ruby ./continuation_script.rb"
end

Andere Tipps

"rvm is not a function" this is because rvm is not load in your enviroment, look up here, see the 3. Reload shell configuration & test and Troubleshooting Your Install.

Also If you want to handled the gems in your project you can use bundler.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top