I want to use per project gemsets. But I don't want to specify the ruby version.
Something like:
#.rvmrc
rvm --create use "#project"
But this give me the following error:
error: Unknown ruby interpreter string component: 'ruby 1.9.2 p136'
info: Now using system ruby.
Is there a way to do what i want?
I'm not sure if that's the case but perhaps
rvm --create use doesn't support params without ruby version.
#.rvmrc
rvm gemset create "project"
rvm gemset use "project"
I didn't check this, just saw at:
http://rvm.beginrescueend.com/gemsets/creating/
Related
I want to create a gemset with a specific patch version of ruby. Generally I use
rvm use 2.0.0#billslim --create
without issue, however i need to use 2.0.0p481, but specifying p481 doesn't work e.g.
rvm use 2.0.0-481#billslim --create
and if i only use 2.0.0 it always try to install p594.
I've tried
rvm use 2.0.0-481#billslim --create
rvm use 2.0.0p481#billslim --create
rvm use 2.0.0#billslim -l 481 --create
rvm --ruby-version use 2.0.0p481 # unknown ruby string, BUT
rvm --ruby-version use ruby-2.0.0p481 # also gives unknown ruby string
adding a .ruby-version file in my repository root e.g. echo 'ruby-2.0.0p481' > .ruby-version
different formats of the strings e.g. ruby-2.0.0 and ruby-2.0.0-p481 but these result in 'unknown ruby string'
nothing works...
the rvm.io docs don't seem to mention patch versions much when doing gem sets
the other info suggests patch versions should work the suggested formats don't work.
of course the only combination i didn't try, works!
rvm use ruby-2.0.0-p481#billslim --create
doh!
I have a Chef recipe which installs RVM and Ruby. in the recipe I am using the execute resource to run the following command:
rvm alias create default 2.0
but this does not set my default Ruby version to 2.0. If I run this command directly on the host it does work because when I type ruby -v the version is set to 2.0 but when I try to run it through the Chef recipe ruby -v still returns 1.8.
This is my resource declaration:
execute "set_ruby_to_version_#{version}" do
command "rvm alias create default #{version}"
action :run
end
How come it doesn't work through the Chef recipe? I know that there is a cookbook available to deal with RVM but I still want to know why this is not working.
since rvm 1.25 rvm does not create wrappers in $rvm_path/bin if you depend on this wrappers (it's already in your PATH) then run this after creating alias:
rvm wrapper default --no-prefix
if you need a wrapper for specific gem add it's name after the command, ex:
rvm wrapper default --no-prefix haml
it will create only this wrapper: $rvm_path/bin/haml
other approach would be adding the automatically generated wrappers to PATH:
PATH=$rvm_path/gems/ruby-2.1.0/wrappers:$PATH
rvm alias create default 2.1.2
rvm use 2.1.2
Works for me.
Just getting started with Ruby.
I am trying to use rvm. Now, for Project A I am trying to specify a specify Ruby version and a gemset.
$ cat projecta/.rvmrc
rvm 1.8.7#projecta
My understanding is that the part before # specifies the Ruby version and the the part after # specifies the gemset name. A gemset IMU is to provide a project specific isolated location where you can install gems.
After I check-in this project, what can I do to automate the process of creating the gemset and installing the correct Ruby version for someone else checking the project out at a later date?
Please suggest appropriate alternatives, since I am just getting started with Ruby today.
The Old Way
to make sure gemset / ruby is available use this .rvmrc:
rvm use 1.8.7#projecta --install --create
It will install ruby if missing and create gemset if missing.
And a special note, please do not use 1.8.7, it's deprecated ruby, with almost no support (security patches till half of 2013), you should stick with latest available ruby:
rvm use ruby
which at this time is: 1.9.3-p194
Add On-Demand Syntax
Your syntax won't work as written. If you want to force people to compile rubies and create gemsets on demand, rather than being warned when things don't exist, you want a project .rvmrc file like this:
# Compile rubies on demand.
rvm_install_on_use_flag=1
# Create gemsets on demand.
rvm_gemset_create_on_use_flag=1
# Use ruby-1.8.7 while in project tree.
rvm use 1.8.7
# Use gemset "projecta" while in project tree.
rvm gemset use projecta
There are certainly other ways to do it, but this way makes everything explicit, and you can comment out individual lines if you need to do so.
See Also
https://rvm.io/workflow/rvmrc/
I am on a VM (Lucid 64b) with a system Ruby version of 1.9.3p0.
I have a Ruby script that creates a .deb file -- The script needs to use Ruby 1.8.7 which I have installed in /foo/ruby/1.8.7.
There is an existing Gemfile to be used with Bundler
I can't use RVM and I can't install gems at the system level.
My .bashrc includes (and has been sourced)
export PATH=$PATH:/foo/ruby/1.8.7/bin
but ruby -v still gives me
ruby 1.9.3p0 (2011-10-30) [x86_64-linux]
Questions
How can I change the Ruby version for my user to use Ruby 1.8.7?
I've run: bundle install --path vendor/bundle
So in that directory (actually ./vendor/bundle/ruby/1.8/cache/gems) are all the gems I need but, when I run the Ruby script it doesn't find the required gems. I run the script like so /foo/ruby/1.8.7 script_to_gen_deb_file.rb
How can I get ruby to see/use the bundled gems?
Update
I was able to solve it. I needed to use
/foo/ruby1.8.7/bundle exec /foo/ruby1.8.7/ruby script_to_gen_deb_file.rb
I had tried this before, but I got an unrelated error and believed there was an environment problem.
Change your path so the special ruby gets precedence?
export PATH=/foo/ruby/1.8.7/bin:$PATH
Is there a way to automatically load rvm on start up?
Every time I open a new terminal window I need to type rvm 1.9.2 to be able to use the gem set. Can I add 1.9.2 as a default?
There are several ways
The normal one is
rvm use 1.9.2 --default
You could also create a file .rvmrc which can also load a specific gemset per folder. For example if you have an application that uses the gemset 1.9.2#myapp, your .rvmrc in myapp could be:
# myapp/.rvmrc
rvm use 1.9.2#myapp --create
you should be able to simply do this;
rvm --default use 1.9.2