RVM setting default ruby is temporary - ruby

So I've been trying to set my default Ruby version to 2.1.2, but I also have 2.0.0 installed and use it occasionally. When I run the command rvm use --default 2.1.2, it works, displaying Using /home/ben/.rvm/gems/ruby-2.1.2 like it should. If I run ruby -v, it returns 2.1.2. Everything's fine there.
However, if I open a new terminal window, and I run ruby -v, it displays 2.0.0. If I do rvm list, it displays the following:
➜ ~ rvm list
rvm rubies
=> ruby-2.0.0-p481 [ x86_64 ]
* ruby-2.1.2 [ x86_64 ]
# => - current
# =* - current && default
# * - default
It basically says that version 2.1.2 is the default, but it is currently using 2.0.0. I don't understand why this would happen, if it is the default, it should start up using that one.

rvm --default use 2.1.2
.......................................

Close, but not quite. From rvm help use:
To set a ruby as the user default, use the --default option.
$ rvm use 1.9.3 --default
edit: as 7stud posted, it works with --default before as well, just not in the middle.

Related

Installing Ruby 2.2.3 on Ubuntu

This problem probably has an obvious answer to anyone who has used Ruby on linux for a long time, but I can't really get a good answer via Google.
I'm trying to check out the Rails 5 beta, which requires Ruby 2.2.2 or greater. I've installed the RVM (Ruby Version Manager) and set my ruby version to 2.2.3. Running rvm list in the terminal results in the following output:
rvm rubies
=* ruby-2.2.3 [ x86_64 ]
# => - current
# =* - current && default
# * - default
Okay, great. I have Ruby 2.2.3 installed. Let's try bundle update:
Installing rack 2.0.0.alpha (was 1.6.4)
Gem::InstallError: rack requires Ruby version >= 2.2.2.
Okay, that's weird. What version of ruby do I have? Running ruby -v gives me this:
ruby 2.1.5p273 (2014-11-13) [x86_64-linux-gnu]
So... do I have 2.2.3 or not? What gives?
Since you are using bundle, I would suggest you to check your Gemfile for ruby version. You can also test it with bundle exec ruby -v
Also try:
rvm use ruby-2.2.3
bundle exec ruby -v
Maybe by setting the default Ruby version on rvm to the one you have (ruby-2.2.3) solves the problem, by doing rvm --default use ruby-2.2.3. Then reload the bash and execute ruby -v to check if the default version of Ruby was changed properly and then try again to execute the bundle install command.
If you don't know zsh and oh-my-zsh, I highly recommend for this kind of things. You could configure the terminal in order to show you the current version of Ruby and Rails that you're using every moment. Check it here: http://ohmyz.sh/
In addition to doing rvm use --default 2.2.3 or rvm use 2.2.3 make sure that you don't have the ruby package from apt (or whatever package manager) still installed. For some reason, that ruby package could take precedence over an RVM Ruby.
Also, try doing rvm uninstall 2.1.5 to force your system to default to 2.2.3... You can always reinstall 2.1.5 later and, if this issue persists, 2.2.3 should stick as your default.

DIfferent versions of ruby in ubuntu

I recently started following M Hartls tutorials on how to build a simple app using RoR.
I nearly wasted one full day on installing RVM and the ruby, since the default RVM on ubuntu is buggy. Once I install ruby through RVM
curl -L https://get.rvm.io | bash -s stable --ruby
it says it installed ruby 2.x version.
but when I type
ruby -v
It says the ruby version is 1.8.x. Why is that?
Your default ruby version is set to 1.8.x.
Type "rvm list" to list installed ruby versions "*" will appear next to your default.
Type "rvm use x.x.x" to use a different version of ruby.
To set a different default version of ruby type "rvm --default use x.x.x".
I think you missed the message given after installing RVM. It's something like:
Please make sure the following line is somewhere in your .bashrc:
source /home/<username>/.rvm/scripts/rvm
What is the output of ruby -v after you executed that line in the console?
If you are using RVM then:
do
rvm list
this will show list of installed rubies
and the do
rvm use XXXXXXX
XXXXX means the version you want to use from the list.
This will use the specified ruby. but after opening new terminal it might be again changed automatically. To avoid this use :
rvm use XXXXXX --default
For example of mine system:
rvm list
rvm rubies
ruby-1.9.3-p545 [ x86_64 ]
=* ruby-2.0.0-p451 [ x86_64 ]
# => - current
# =* - current && default
# * - default
$ rvm use 2.0.0
Using .rvm/gems/ruby-2.0.0-p451
$ rvm use 2.0.0 --default
Using .rvm/gems/ruby-2.0.0-p451

rvm resetting the default

These are the rubies I have installed with RVM
rvm rubies
ruby-1.8.7-head [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-rc1 [ x86_64 ]
I have a lot of gemsets for 1.9.2
gemsets for ruby-1.9.2-p290 (found in /Users/mm/.rvm/gems/ruby-1.9.2-p290)
19332
309
clone
devise
devise311
enki
global
rails3
rails301
rails303
rails304
rails310
rails313
rails32
rails323
rails3tutorial
railsValim
However, when I tried to use one of them, it said it didn't exist
rvm use 1.9.2#rails304
ERROR: Gemset 'rails304' does not exist, rvm gemset create 'rails304' first.
WARN: Gemset doesn't exist, proceeding with default gemset
WARN: ruby ruby-1.9.2-use1.9.2 is not installed.
To install do: 'rvm install ruby-1.9.2-use1.9.2'
Please notice the reference to the version of Ruby in the last line
To install do: 'rvm install ruby-1.9.2-use1.9.2'
This is different than the ruby listed above
ruby-1.9.2-p290 [ x86_64 ]
I don't know where the Ruby with 'use1.9.2' at the end came from. Maybe I screwed up somehow by trying to do something like rvm use 1.9.2 so the word 'use' got stuck together with 1.9.2., so I tried to set the other rvm ruby (p290) as the default
rvm use ruby-1.9.2-p290 --default
Using /Users/me/.rvm/gems/ruby-1.9.2-p290
but when I did that and tried to use one of its gemsets, it said it didn't exist
rvm use 1.9.2#rails304
ERROR: Gemset 'rails304' does not exist, rvm gemset create 'rails304' first.
WARN: Gemset doesn't exist, proceeding with default gemset
WARN: ruby ruby-1.9.2-use1.9.2 is not installed.
To install do: 'rvm install ruby-1.9.2-use1.9.2'
and again, it had reference to this other ruby version 'ruby-1.9.2-use.1.9.2' with that funny 'use.1.9.2' on the end.
I don't know if this is my human error, or something that's resulting from my recent installation of Mountain Lion, which caused some other system changes on my computer.
How would I go about getting 'ruby-1.9.2-use.1.9.2' off my system and using the ruby 1.9.2 listed when I do the command rvm rubies
ruby-1.8.7-head [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.3-rc1 [ x86_64 ]
i don't know why synonym "rvm use 1.9.2" stop working and shows such a strange behavior but
assuming using the exact name of rubie work, you can try to specify gemset like this
rvm use ruby-1.9.2-p290#rails304
or to setup as default
rvm use ruby-1.9.2-p290#rails304 --default
Here's some information for understanding the behavior of rvm use
When you run rvm list known it will list rubies in the following format:
[ruby-]1.9.2[-p320]
[ruby-]1.9.3-p125
[ruby-]1.9.3-p194
[ruby-]1.9.3-p286
[ruby-]1.9.3-p327
[ruby-]1.9.3[-p362]
The parts contained in [] are optional to type in. Therefore, doing rvm use 1.9.3 would attempt to use 1.9.3-p362 as it is considered the best 1.9.3 version to use. If you don't have it installed, it will ask you to install it first. That means, when you installed ruby-1.9.2 it probably installed p290 as it was the latest version and that is no longer the case after upgrading RVM to a newer version. Therefore, to use your gemsets for the version you have installed, you need to do rvm use ruby-1.9.2-p290#GEMSET.

Can't find Ruby 1.9.2 after installing RVM

I'm on Linux Ubuntu 12.04, and I first installed Ruby 1.9.2.
After I tried installing rvm to use Octopress, ruby --version in bash results in ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
How can I use RVM with ruby 1.9.2?
I don't really understand what RVM is all about...
The 1.9.2 version you installed first is not accessible from rvm.
While working with rvm, only the list of rubies installed through rvm is served. The previously installed versions of ruby - while still present in the filesystem - are not included.
With the steps you have done so far, you have a 1.9.2 version installed in one location, and a 1.8.7 version installed as part of rvm.
Install 1.9,2 version by running the rvm install 1.9.2 command. After that, when you run the rvm list command, you should see an output similar to the following:
$ rvm list
rvm rubies
ruby-1.8.7-p358 [ i686 ]
=* ruby-1.9.2-p320 [ x86_64 ]
# => - current
# =* - current && default
# * - default
You can switch between different versions of ruby managed by rvm with the rvm use 1.8.7 / rvm use 1.9.2 commands.
Here's a short blogpost with a good intro to rvm: Get started right with RVM
RVM is a version manager which enables you to decide which of multiple installed Ruby versions you want to use in your current shell session. RVM does this by providing a shell function named rvm which can be used to switch between versions in the current session. This changes environment variables, especially the GEM_HOME and PATH, to match the currently selected Ruby installation.
Every installed Ruby version can be selected by a specific identifier string. If you had a system-wide Ruby installation already before you installed RVM, that one should be referenced by the string system. The newly installed version in your case should be called 1.9.2.
To make RVM work as intended, it is necessary to load the rvm shell function into your shell. How to do this is described in the RVM Installation Documentation in section 2 - "Load RVM into your shell sessions as a function".
You can see if the shell function is correctly loaded when the command type rvm | head -n1 responds with:
rvm is a shell function
If not correctly loaded it will tell you something like this:
rvm is /home/someone/.rvm/bin/rvm
If you finally have it working you can switch your active Ruby version with commands like rvm 1.9.2 or rvm system. You can get a list of all Ruby versions and their identifier strings recognized by RVM by the command rvm list.
You can also specify which Ruby version shall be enabled in all new shell sessions from the beginning by issuing the following command once:
rvm --default 1.9.2
Perhaps you have not yet switched to the ruby version with:
rvm use 1.9.2 (assuming you did rvm install 1.9.2)
for a more general explanation I gave an answer here which might help.

Ruby 1.8.7 upgrade to ruby 1.9.2

I am going through this tutorial, but I already had Ruby 1.8.7 installed. I need to have 1.9.2/1.9.3 version.
I started to use RVM.
$ rvm list rubies
rvm rubies
ruby-1.8.7-p358 [ x86_64 ]
ruby-1.9.2-p318 [ x86_64 ]
=* ruby-1.9.2-p320 [ x86_64 ]
ruby-1.9.3-p194 [ x86_64 ]
# => - current
# =* - current && default
# * - default
but if I run ruby -v it returns still 1.8.7.
$ ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
other return values:
$ whereis ruby
ruby: /usr/bin/ruby /usr/bin/ruby1.8 /usr/lib/ruby /usr/share/man/man1/ruby.1.gz
$ which rails
/usr/local/bin/rails
$ which ruby
/usr/bin/ruby
When you're typing ruby you're still hitting the system ruby, not the rvm ruby.
Did you follow all the directions here: https://rvm.io//rvm/install/ ?
It looks like you're running Linux -- did you see this section in the rvm install docs?
If you open a new shell and running:
$ type rvm | head -1
does not show "rvm is a function", RVM isn't being sourced correctly.
Ensure that RVM is sourced after any path settings as RVM and manipulates the path. If you don't do this, RVM may not work as expected.
If you are using GNOME on Red Hat, CentOS or Fedora, ensure that the Run command as login shell option is checked under the Title and Command tab in Profile Preferences. After changing this setting, you may need to exit your console session and start a new one before the changes take affect.
Also, rvm adds some lines to your .bashrc file to load itself into memory whenever you open a console session. It looks like this may be your issue.
In my .bashrc, for example, rvm inserted the following:
export PATH=/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql84/bin:$PATH
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
Is there something similar in yours? Also, if you're using z-shell you may need to take some extra steps that are outlined in the install docs.
Try
$ rvm use ruby-1.9.2-p320
then
$ ruby -v
what does this return?
This should change your ruby version to ruby-1.9.2-p320 in the current console and if you want it on every new opened terminal you may use --default option
try
$ rvm --default use ruby-1.9.2-p320
then
$ruby -v
should return ruby-1.9.2-p320 version in the current and in every new window terminal opened.
Any time you want to return to your system ruby installation
use
$ rvm use system

Resources