How do I change my Ruby version using RVM?
Fixed it. I needed to add:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM
to .zshrc
How to change ruby version
There is lots of advise in the comments to your question, some of it is advanced-ish rbenv or rvm usage.
My advice: Decide on how to manage multiple rubies - either use your OS package manager (in your case the apt-get
/PPA stuff) OR rvm OR rbenv.
For the OS package manager, there should be a way to call ruby with version explicitely (e.g. /usr/bin/ruby1.9.3
), or research on and call update-alternative
. As bundler comes with a gem, you might get the interpreters confused here.
For rvm, change ruby version with rvm use 2.5.1
(once it is installed).
For rbenv I actually do not know but it should be trivial, too (and people are happy with it; it just happens that I tried rvm first and it worked like a charm, never evaluated rbenv).
I usually install one "system" ruby (apt-get install ruby1.9.3) and use rvm afterwards. You can still switch to the packaged "production" ruby with rvm use system
.
Update 2017: Most distros ship with a ruby version installed already, so you probably don't have to install it manually. Run ruby -v
or which ruby
to see if a ruby interpreter is already installed.
In your case I would probably deinstall all system rubys (apt-get purge ...
), remove the PPAs, remove your ~/.rvm and rbenv and start from scratch (install packaged stable ruby, then rvm and use rvm (r.g. rvm install 2.3.1
) from there on).
How do I upgrade my ruby 1.9.2-p0 to the latest patch level using rvm?
First of all, update your RVM installation by running rvm get stable
.
To make sure you're running the new RVM version, you'll then need to run rvm reload
(or just open a new terminal).
Once that's done, you can ask RVM to list the ruby versions available to install by running rvm list known
.
In the output you should now see:
# MRI Rubies
...
[ruby-]1.9.2[-p320]
...
The square brackets around the patch level indicate that this is currently RVM's default patch level for ruby 1.9.2.
Finally, to install the new ruby version, just run rvm install 1.9.2
- and wait for it to compile!
RVM not keeping ruby version
In the rvm list
we clearly see the default is set correctly (marked with the asterisk), so check your current folder for the presence of a .rvmrc
or .ruby-version
file which will overrule the rvm default version.
How can I change Ruby to version 1.9.3 (again) with RVM?
You are not in the login shell. To enter the login shell try this command:
/bin/bash --login
After that you will be able to use RVM to select Ruby.
Also, there is permanent way, that you won't have to write this line everytime you open your terminal.
Try this:
Edit menu -> Profile Preferences
A dialog will appear, now select Run command in login shell
.
After that, whenever you open your terminal, you will enter into the login shell, and you will be able to use RVM.
There is another way, you can write /bin/bash --login
in your .bash_profile
which will load every time when you reboot.
Can't change default Ruby version in RVM
I'm not sure what command you're using to change the ruby version in rvm, you didn't specify. My hunch is you're using rvm use
, this is only temporary for the shell session. To change it permanently use rvm default
:
rvm --default use ruby-2.1.0
This change will persist to new shell sessions.
How do I set a default Ruby version using RVM?
You can install whichever version you like, for example rvm install ruby-1.9.3-p392
. Then you can make this the default by using rvm use --default ruby-1.9.3-p392
. You must install
before you can use
.
See the cheat sheet for a brief overview or consult the comprehensive documentation indexed at the bottom of the page here: https://rvm.io/
Your second question regarding MySQL should be filed separately (chances are you haven't yet started the MySQL server).
Related Topics
Pass Variables to Ruby Script Via Command Line
Why Does Ruby Have Both Private and Protected Methods
Using Rails Serialize to Save Hash to Database
How to Determine If One Array Contains All Elements of Another Array
Test If String Is a Number in Ruby on Rails
Require': Cannot Load Such File - 'Nokogiri\Nokogiri' (Loaderror) When Running 'Rails Server'
Gem Installation Error: You Have to Install Development Tools First (Windows)
Save Image from Url by Paperclip
How to Split (Chunk) a Ruby Array into Parts of X Elements
How Does Instance_Eval Work and Why Does Dhh Hate It
Ruby: Kind_Of? Vs. Instance_Of? Vs. Is_A
Why Does Installing Nokogiri on MAC Os Fail With Libiconv Is Missing
What Does ||= (Or-Equals) Mean in Ruby
How to Assign a Variable in an If Else Statment Check
How to Find Where a Method Is Defined At Runtime