How to Set Default Ruby Version with Rvm

How to set default Ruby version with RVM?

If you put the RVM source line in your bashrc (in order to ensure that non-interactive shells have access to RVM), you will need to source .bashrc from your .bash_profile with the following as the last lines in your .bash_profile

if [ -f "$HOME/.bashrc" ]; then
source $HOME/.bashrc
fi

This pre-supposes that you have

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"

in your $HOME/.bashrc. This is a good way to ensure that both interactive/login and non-interactive shells are able to find and load RVM correctly. Multi-User installs accomplish the same thing via the /etc/profile.d/rvm.sh file.

After that, you should have no problems defining a default Ruby to use via

rvm 1.9.2 --default

or

rvm use 1.9.2@mygemset --default

Its better to define a default gemset to use so as not to pollute your 'default' or 'global' gemsets.

If you are using non-interactive shells, be aware that they genereally operate in SH-compatibility mode which then requires you to set

BASH_ENV="$HOME/.bashrc"

in your $HOME/.profile in order you load RVM, or to set that within your script directly. The reason for this is that when bash is operating in SH mode it does not directly load .bash_profile or .bashrc as SH doesn't use those files, and bash is attempting to mimic the loading and execution process of the SH shell.

RVM: Can set the default ruby version but cannot set the current version

For me following command doing the work

rvm --default use 2.2.2

You might have issue with login shell and required to use /bin/bash --login as the command

How to tell RVM (Ruby Version Manager) to remember my set default when I open a new terminal window

If you want to install a specific version of Ruby (2.5.1), you can use this:

rvm install ruby-2.5.1
rvm --default use ruby-2.5.1

If you wanted to install and use the latest version of Ruby, you can use the following:

rvm install ruby
rvm --default use ruby

How to set default ruby version using rvm

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.

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).

how to set default ruby with rvm

Typing rvm list will give you a list of the installed rubies you have, like this:

    ree-1.8.7-2010.02 [ i686 ]
ruby-1.8.7-p249 [ i686 ]
ruby-1.9.2-p180 [ x86_64 ]
ruby-1.9.2-p180-patched [ x86_64 ]
ruby-1.9.2-p290 [ x86_64 ]
ruby-1.9.2-p290-webkit [ x86_64 ]
=* ruby-1.9.3-p194 [ x86_64 ]

If the one you want is ruby-1.9.3-p194, then type:

rvm --default use  ruby-1.9.3-p194

First, be careful to follow the installation instructions closely and make sure it's working.

You should also see this line in your bashrc as well:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"  

Then try opening a new shell or try typing:

source ~/.rvm/scripts/rvm

But in general if you're having issues, I'd recommend just re-installing rvm -- it doesn't take long and it's easy:

curl -L get.rvm.io | bash -s stable

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.

Set a default Ruby version for a specific directory (RVM)

One way is to use a Gemfile and set the ruby version in it. like so:

ruby '2.2.0'

then when you enter the directory you will see the following message from rvm

RVM used your Gemfile for selecting Ruby, it is all fine - Heroku does that too,
you can ignore these warnings with 'rvm rvmrc warning ignore /Users/danmanstx/rails_projects/app/Gemfile'.
To ignore the warning for all files run 'rvm rvmrc warning ignore allGemfiles'.


Related Topics



Leave a reply



Submit