rvm - default version of ruby - ruby

I did this a few days ago:
$ rvm --default use 2.1.5
but then when I ran ruby -v today I got:
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
Is there a better way to permanently set the version of Ruby I use?
==== UPDATE
$ rvm use
Using /Users/snowcrash/.rvm/gems/ruby-2.1.5
$ which rvm
/Users/snowcrash/.rvm/bin/rvm
$ which ruby
/Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin/ruby
and output of rvm info (note that ruby has reverted back to 2.0.0p481):
$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
$ rvm info
ruby-2.1.5:
system:
uname: "Darwin w.local 14.0.0 Darwin Kernel Version 14.0.0: Fri Sep 19 00:26:44 PDT 2014; root:xnu-2782.1.97~2/RELEASE_X86_64 x86_64"
system: "osx/10.10/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.53(1)-release (x86_64-apple-darwin14)"
zsh: "/bin/zsh => zsh 5.0.5 (x86_64-apple-darwin14.0)"
rvm:
version: "rvm 1.26.9 (latest) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "8 days 7 hours 2 minutes 42 seconds ago"
path: "/Users/snowcrash/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p481"
date: "2014-05-08"
platform: "universal.x86_64-darwin14"
patchlevel: "2014-05-08 revision 45883"
full_version: "ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]"
homes:
gem: "/Users/snowcrash/.rvm/gems/ruby-2.1.5"
ruby: "/Users/snowcrash/.rvm/rubies/ruby-2.1.5"
binaries:
ruby: "/usr/bin/ruby"
irb: "/usr/bin/irb"
gem: "/usr/bin/gem"
rake: "/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin/rake"
environment:
PATH: "/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin:/Users/snowcrash/.apportable/SDK/bin:/Library/Frameworks/Python.framework/Versions/2.6/bin:/opt/local/bin:/opt/local/sbin:/Library/Frameworks/Python.framework/Versions/Current/bin:/usr/bin:/Users/snowcrash/Library/ec2-api-tools-1.3-24159/bin:/Users/snowcrash/bin:/Users/snowcrash/Library/android-sdk-mac_86:/Users/snowcrash/Library/android-sdk-mac_86/platform-tools:/Users/snowcrash/Library/bin:/usr/local/mysql/bin:/usr/local/bin:/Library/PostgreSQL/9.1/bin:/usr/local/sbin:/Users/snowcrash/.rvm/gems/ruby-2.1.5/bin:/Users/snowcrash/.rvm/gems/ruby-2.1.5#global/bin:/Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/snowcrash/.rvm/bin:/Users/snowcrash/bin/gsutil:/usr/local/graphviz-2.14/bin:/Users/snowcrash/.rvm/bin"
GEM_HOME: "/Users/snowcrash/.rvm/gems/ruby-2.1.5"
GEM_PATH: "/Users/snowcrash/.rvm/gems/ruby-2.1.5:/Users/snowcrash/.rvm/gems/ruby-2.1.5#global"
MY_RUBY_HOME: "/Users/snowcrash/.rvm/rubies/ruby-2.1.5"
IRBRC: "/Users/snowcrash/.rvm/rubies/ruby-2.1.5/.irbrc"
RUBYOPT: ""
gemset: ""

Your PATH contains /usr/bin multiple times, the first of which is before /Users/snowcrash/.rvm/rubies/ruby-2.1.5/bin, so the system provided ruby is added first.
You seem to have a lot of entries in there - review your shells initialisation files (.bashrc, .bash_profile etc) and check anything that manipulates $PATH

What does stuff like rvm use, which rvm or which ruby say? That looks like the system Ruby, which to me means you don't have rvm properly installed and you opened a new terminal session and got the system version.
Or, the command was entered wrong. rvm use --default 2.1.5
After that, rvm list will show it marked as default.
(nick#blerp)-(~)
(507)⚡️ rvm use --default 2.2.0
Using /Users/nick/.rvm/gems/ruby-2.2.0
(nick#blerp)-(~)
(508)⚡️ rvm list
rvm rubies
=* ruby-2.2.0 [ x86_64 ]
# => - current
# =* - current && default
# * - default
You could always reinstall rvm (doesn't hurt to reinstall on top) and make sure the path settings are in your shell dotfiles.

Related

Despite RVM-plugin Jenkins uses wrong ruby version

Jenkins is running on an ubuntu machine. It has a special user jenkins which is used for executing the jobs.
RVM is installed and in an ssh shell on the server, logged in as the jenkins user, everything works fine.(If I set RVM to use ruby 1.9.3 ruby -vreturns 1.9.3 as version)
I use the RVM-plugin for Jenkins and have set it to use 1.9.3
Output by Jenkins for RVM:
Capturing environment variables produced by 'rvm use 1.9.3'
$ bash -c export
$ bash -c "test -f ~/.rvm/scripts/rvm"
$ bash -c "test -f /usr/local/rvm/scripts/rvm"
[workspace] $ bash -c " source /usr/local/rvm/scripts/rvm && rvm use --install --create 1.9.3 && export > rvm.env"
Using /usr/local/rvm/gems/ruby-1.9.3-p0
However if I later want to execute my script it uses ruby version 1.8.7.
Output for ruby version and environment:
+ which ruby
/usr/bin/ruby
+ ruby -v
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
+ rvm info
ruby-1.9.3-p0:
system:
uname: "Linux h1332957.stratoserver.net 2.6.32-042stab078.27 #1 SMP Mon Jul 1 20:48:07 MSK 2013 i686 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin#gmail.com [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2010-01-10"
platform: "i486-linux"
patchlevel: "2010-01-10 patchlevel 249"
full_version: "ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]"
homes:
gem: "/usr/local/rvm/gems/ruby-1.9.3-p0"
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
binaries:
ruby: "/usr/bin/ruby"
irb: "/usr/bin/irb"
gem: "/usr/bin/gem"
rake: "/usr/bin/rake"
environment:
PATH: "/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/rvm/bin:/usr/local/rvm/bin"
GEM_HOME: "/usr/local/rvm/gems/ruby-1.9.3-p0"
GEM_PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0:/usr/local/rvm/gems/ruby-1.9.3-p0#global"
MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
IRBRC: "/usr/local/rvm/rubies/ruby-1.9.3-p0/.irbrc"
RUBYOPT: ""
gemset: ""
Question:
How can I make Jenkins use ruby version 1.9.3 instead?
I solved the problem by sourcing rvm.
I updated my script to look like this:
#!/bin/bash
source "/usr/local/rvm/scripts/rvm"
rvm use 1.9.3
rvm info
Now the output by rvm info is correct.
Most important are the first and second line.
Output by rvm info:
ruby-1.9.3-p0:
system:
uname: "Linux h1332957.stratoserver.net 2.6.32-042stab078.27 #1 SMP Mon Jul 1 20:48:07 MSK 2013 i686 GNU/Linux"
bash: "/bin/bash => GNU bash, version 4.1.5(1)-release (i486-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.3p0"
date: "2011-10-30"
platform: "i686-linux"
patchlevel: "2011-10-30 revision 33570"
full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]"
homes:
gem: "/usr/local/rvm/gems/ruby-1.9.3-p0"
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
binaries:
ruby: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby"
irb: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/irb"
gem: "/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/gem"
rake: "/usr/local/rvm/gems/ruby-1.9.3-p0/bin/rake"
environment:
PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0/bin:/usr/local/rvm/gems/ruby-1.9.3-p0#global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p0/bin:/usr/local/rvm/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
GEM_HOME: "/usr/local/rvm/gems/ruby-1.9.3-p0"
GEM_PATH: "/usr/local/rvm/gems/ruby-1.9.3-p0:/usr/local/rvm/gems/ruby-1.9.3-p0#global"
MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p0"
IRBRC: "/usr/local/rvm/rubies/ruby-1.9.3-p0/.irbrc"
RUBYOPT: ""
gemset: ""
Rvm creates a environment file on your workspace called "rvm.env". If you add:
source rvm.env
to all your shell scripts, you'll get the right environment without having to set up rvm manually.
Adding "rvm use x.x.x" didn't work for me. But it did produce a helpful error message:
RVM is not a function, selecting rubies with 'rvm use ...' will not work.
You need to change your terminal emulator preferences to allow login shell.
Sometimes it is required to use /bin/bash --login as the command.
Please visit https://rvm.io/integration/gnome-terminal/ for an example.
My terminal emulator was already allowing login shell too.
Adding "--login" to the bash call got it to work.

rvm info has different version that ruby

After installing rvm and modifying my .zshrc file when running rvm info i get a different version that when i type ruby -v and when trying to install a gem i get a bunch of errors relating to the system ruby
rvm info output:
$ rvm info
ruby-2.1.1:
system:
uname: "Darwin Joshs-MacBook-Pro.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64"
system: "osx/10.9/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.51(1)-release (x86_64-apple-darwin13)"
zsh: "/bin/zsh => zsh 5.0.2 (x86_64-apple-darwin13.0)"
rvm:
version: "rvm 1.25.20 (stable) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "3 hours 4 minutes 13 seconds ago"
path: "/Users/joshburns/.rvm"
ruby:
interpreter: "ruby"
version: "2.0.0p247"
date: "2013-06-27"
platform: "universal.x86_64-darwin13"
patchlevel: "2013-06-27 revision 41674"
full_version: "ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]"
homes:
ZSH=$HOME/.oh-my-zsh
gem: "/Users/joshburns/.rvm/gems/ruby-2.1.1"
ruby: "/Users/joshburns/.rvm/rubies/ruby-2.1.1"
binaries:
ruby: "/usr/bin/ruby"
irb: "/usr/bin/irb"
gem: "/usr/bin/gem"
rake: "/Users/joshburns/.rvm/gems/ruby-2.1.1/bin/rake"
environment:
PATH: "/Users/joshburns/.rvm/gems/ruby-2.1.1/bin:/Users/joshburns/.rvm/gems/ruby-2.1.1#global/bin:/Users/joshburns/.rvm/rubies/ruby-2.1.1/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/joshburns/bin:/Users/joshburns/.rvm/bin"
GEM_HOME: "/Users/joshburns/.rvm/gems/ruby-2.1.1"
GEM_PATH: "/Users/joshburns/.rvm/gems/ruby-2.1.1:/Users/joshburns/.rvm/gems/ruby-2.1.1#global"
MY_RUBY_HOME: "/Users/joshburns/.rvm/rubies/ruby-2.1.1"
IRBRC: "/Users/joshburns/.rvm/rubies/ruby-2.1.1/.irbrc"
RUBYOPT: ""
gemset: ""
ruby -v output:
ruby 2.0.0p247 (2013-06-27 revision 41674) [universal.x86_64-darwin13]
I think I have had a similar problem but found the solution here:
http://www.intelligentbee.com/blog/2013/09/17/setup-a-simple-ruby-2-on-rails-4-environment-with-vagrant-and-virtual-box/
Look for the bit:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
rvm use ruby-2.0.0-p247 (replace with your ruby version)

How to set default ruby version using rvm

I've set my default ruby version with
rvm use 1.9.3 --default
When opening a new terminal I can see that rvm remembers my default, however the old version of ruby is used:
Last login: Tue Jan 22 17:36:20 on ttys000
➜ ~ rvm list default
Default Ruby (for new shells)
ruby-1.9.3-p374 [ x86_64 ]
➜ ~ ruby -v
ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]
➜ ~ rvm info
ruby-1.9.3-p374:
system:
uname: "Darwin murzemac.local 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64"
system: "osx/10.8/x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin12)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin12.0)"
rvm:
version: "rvm 1.17.10 () by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "14 hours 46 minutes 38 seconds ago"
ruby:
interpreter: "ruby"
version: "1.8.7"
date: "2012-02-08"
platform: "universal-darwin12.0"
patchlevel: "2012-02-08 patchlevel 358"
full_version: "ruby 1.8.7 (2012-02-08 patchlevel 358) [universal-darwin12.0]"
homes:
gem: "/Users/murze/.rvm/gems/ruby-1.9.3-p374"
ruby: "/Users/murze/.rvm/rubies/ruby-1.9.3-p374"
binaries:
ruby: "/usr/bin/ruby"
irb: "/usr/bin/irb"
gem: "/usr/bin/gem"
rake: "/usr/bin/rake"
environment:
PATH: "/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/murze/.rvm/bin"
GEM_HOME: "/Users/murze/.rvm/gems/ruby-1.9.3-p374"
GEM_PATH: "/Users/murze/.rvm/gems/ruby-1.9.3-p374:/Users/murze/.rvm/gems/ruby-1.9.3-p374#global"
MY_RUBY_HOME: "/Users/murze/.rvm/rubies/ruby-1.9.3-p374"
IRBRC: "/Users/murze/.rvm/rubies/ruby-1.9.3-p374/.irbrc"
RUBYOPT: ""
gemset: ""
How can 1.9.3 be automatically activated when opening a new terminal window?
My default doesn't always correctly set either, so I've put a .rvmrc in the directory my terminal opens at (or in dirs my terminal is likely to open at) with rvm use default inside.

Ruby not starting on mac os x

when I try to use ruby with the terminal, nothing happens.
The last days I've used it and everything worked but it doesn't anymore.
I installed rvm and the 1.9.3 version of ruby.
It works when I launch a script with ruby myscript.rb, and I tried installing rails but when I type gem install rails I get an error:
/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/bin/gem:4: warning: Insecure world writable dir /Users/romainberger/.rvm/gems/ruby-1.9.3-p194 in PATH, mode 040777
As there is no output I don't know where the problem comes from. Does anybody have an idea?
Thanks
EDIT:
rvm info
ruby-1.9.3-p194:
system:
uname: "Darwin romain.home 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:47:41 PST 2012; root:xnu-1699.24.23~1/RELEASE_X86_64 x86_64"
bash: "/bin/bash => GNU bash, version 3.2.48(1)-release (x86_64-apple-darwin11)"
zsh: "/bin/zsh => zsh 4.3.11 (i386-apple-darwin11.0)"
rvm:
version: "rvm 1.14.1 (master) by Wayne E. Seguin <wayneeseguin#gmail.com>, Michal Papis <mpapis#gmail.com> [https://rvm.io/]"
updated: "1 day 11 hours 59 minutes 3 seconds ago"
ruby:
interpreter: "ruby"
version: "1.9.3p194"
date: "2012-04-20"
platform: "x86_64-darwin11.3.0"
patchlevel: "2012-04-20 revision 35410"
full_version: "ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.3.0]"
homes:
gem: "/Users/romainberger/.rvm/gems/ruby-1.9.3-p194"
ruby: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194"
binaries:
ruby: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/bin/ruby"
irb: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/bin/irb"
gem: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/bin/gem"
rake: "/Users/romainberger/.rvm/gems/ruby-1.9.3-p194#global/bin/rake"
environment:
PATH: "/Users/romainberger/.rvm/gems/ruby-1.9.3-p194/bin:/Users/romainberger/.rvm/gems/ruby-1.9.3-p194#global/bin:/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/romainberger/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/git/bin"
GEM_HOME: "/Users/romainberger/.rvm/gems/ruby-1.9.3-p194"
GEM_PATH: "/Users/romainberger/.rvm/gems/ruby-1.9.3-p194:/Users/romainberger/.rvm/gems/ruby-1.9.3-p194#global"
MY_RUBY_HOME: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194"
IRBRC: "/Users/romainberger/.rvm/rubies/ruby-1.9.3-p194/.irbrc"
RUBYOPT: ""
gemset: ""
gem info gives me:
ERROR: While executing gem ... (RuntimeError)
Unknown command info
And to launch ruby I just type ruby
To fix the gem warning use:
chmod -R go-w /Users/romainberger/.rvm/
It will recursively remove write right for group and others (keeps write for user).
You can check for RVM related resurces on RVM site: https://rvm.io/

rvm use 1.9.2 leaves me using ruby 1.8.7

I dont understand why after the rvm command I am still on ruby 1.8.7. Ive followed the install instructions for rvm and it all seemed to go fine - where do I look to start resolving this?
andrew#unifex:~$ rvm use 1.9.2 --default
Using /home/andrew/.rvm/gems/ruby-1.9.2-p290
andrew#unifex:~$ ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [x86_64-linux]
andrew#unifex:~$
andrew#unifex:~$ rvm info
ruby-1.9.2-p290:
system:
uname: "Linux unifex 2.6.22-3-amd64 #1 SMP Sun Nov 4 18:18:09 UTC 2007 x86_64 GNU/Linux"
bash: "/bin/bash => GNU bash, version 3.1.17(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
rvm:
version: "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin#gmail.com) [https://rvm.beginrescueend.com/]"
ruby:
interpreter: "ruby"
version: "1.9.2p290"
date: "2011-07-09"
platform: "x86_64-linux"
patchlevel: "2011-07-09 revision 32553"
full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-linux]"
homes:
gem: "/home/andrew/.rvm/gems/ruby-1.9.2-p290"
ruby: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290"
binaries:
ruby: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290/bin/ruby"
irb: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290/bin/irb"
gem: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290/bin/gem"
rake: "/home/andrew/.rvm/gems/ruby-1.9.2-p290/bin/rake"
environment:
PATH: "/home/andrew/.rvm/gems/ruby-1.9.2-p290/bin:/home/andrew/.rvm/gems/ruby-1.9.2-p290#global/bin:/home/andrew/.rvm/rubies/ruby-1.9.2-p290/bin:/home/andrew/.rvm/bin:/usr/local/java/jdk1.6.0_20/bin:/usr/local/apache/maven/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/java/jdk1.6.0_03/bin"
GEM_HOME: "/home/andrew/.rvm/gems/ruby-1.9.2-p290"
GEM_PATH: "/home/andrew/.rvm/gems/ruby-1.9.2-p290:/home/andrew/.rvm/gems/ruby-1.9.2-p290#global"
MY_RUBY_HOME: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290"
IRBRC: "/home/andrew/.rvm/rubies/ruby-1.9.2-p290/.irbrc"
RUBYOPT: ""
gemset: ""
I had this exact problem. It's down to your $PATH not being correct - /usr/bin/ruby is found before rvm gets a chance to do its thing.
In your ~/.bash_profile (As in /Users/andrew/.bash_profile) ensure you have this line present at the bottom of the file:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
Then open a new shell
rvm reload
rvm use 1.9.2 --default
ruby -v
You should now have the correct version displayed.

Resources