How to Upgrade Rvm When the Official Way Doesn't Work

How do I upgrade RVM when the official way doesn't work?

Install RVM from scratch

1) First remove the current version, see: https://stackoverflow.com/a/3558763/1076207

# use sudo at your own discretion
rvm implode --force
gem uninstall rvm
rm -rf ~/.rvm

# open file
vim ~/.bash_profile
# remove lines:
# [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
# close file

2) Follow the directions on the RVM install page: https://rvm.io/rvm/install

rvm installation not working: RVM is not a function

You are not using an login shell.

The process of enabling the login flag is described here, also some details on what a login shell is can be found here.

Thus, you need to check the option "Run as login shell" in the Gnome terminal's settings. It is required to open new terminal after this setting the flag.

Sometimes it is required to set the command to /bin/bash --login.


For remote connections it is important to understand the differene between running interactive ssh session and executing single commands.

While running ssh server and then working with the server interactively you are using login shell by default and it's all fine, but for ssh server "command" you are not using login shell and it would be required to run it with ssh server 'bash -lc "command"'.

Any remote invocation can have the same problem as executing single command with ssh.

RVM installed by Ruby not working?

RVM requires a minor addition to your ~/.bashrc or ~/.bash_profile to initialize it when you log-in. It is specified in the installation docs in the Post Install section. Did you do that?


Per your rvm info output, it looks like you haven't completed your installation. All the entries in the output should have corresponding values. So, I suspect you haven't added:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

to your ~/.bashrc or ~/.bash_profile and then started a new session.

If you are doing a "Multi-User" installation then you'll need to do a lot more. Have you modified /etc/profile, or, if you are using Bash as your shell, have you modified /etc/bash.bashrc to include:


# Load RVM if it is installed,
# first try to load user install
# then try to load root install, if user install is not there.
if [ -s "$HOME/.rvm/scripts/rvm" ] ; then
. "$HOME/.rvm/scripts/rvm"
elif [ -s "/usr/local/rvm/scripts/rvm" ] ; then
. "/usr/local/rvm/scripts/rvm"
fi

and started a new shell?

Personally I don't like the multi-user install as much as the single-user install, and don't recommend it but your mileage might vary.


As a FYI: In a discussion with the RVM maintainers on IRC last year, they told me they do not recommend the system-wide installation, and instead recommend the local "single-user" installation, even for servers.

Safe way to upgrade Ruby versions and gemsets in Rails applications

You can install new versions of Ruby and gem sets all day long without it affecting a running application. Once an application is running, it continues running under the same version of Ruby the entire time.

You can have RVM install new Rubies, manipulate gemsets, etc., as long as you don't remove the version of Ruby the application needs. If the binary disappears your app might crash/lock-up if the system needs to load something that has been deleted.

RVM, where is Ruby 3.0.0?

If you have not updated rvm do that first RVM Upgrading

rvm get stable 
# or
rvm get master # for even newer versions not in stable 3.0.0 in this case

To see all available rubies run

rvm list remote all 
# or
rvm list known # as pointed out in the comments

you should see ruby-3.0.0 in the list of available rubies

Then run

rvm install ruby-3.0.0

rvm list known differs between develop and production

Each RVM version has a hardcoded list of known Ruby versions. If the list differs between installtions, it is generally caused by different RVM versions.

Try to upgrade your RVM version to get the most up-to-date list. With current RVM versions, you can update RVM by running

rvm get latest

Installed Ruby 1.9.3 with RVM but command line doesn't show ruby -v

You have broken version of RVM. Ubuntu does something to RVM that produces lots of errors, the only safe way of fixing for now is to:

sudo apt-get --purge remove ruby-rvm
sudo rm -rf /usr/share/ruby-rvm /etc/rvmrc /etc/profile.d/rvm.sh

open new terminal and validate environment is clean from old RVM settings (should be no output):

env | grep rvm

if there was output, try to open new terminal, if it does not help then restart your computer.

install RVM:

\curl -L https://get.rvm.io | 
bash -s stable --ruby --autolibs=enable --auto-dotfiles

If you find you need some hand-holding, take a look at Installing Ruby on Ubuntu 12.04, which gives a bit more explanation.

How to use RVM --default on MacOSX

I had the same problem once. It turned out the rvm-script got loaded twice, which broke things a bit.

Check all the files that load when you open a shell:

/etc/profile
~/.bashrc
~/.bash_profile

and so on, and make sure they don't load RVM twice.

Maybe put

echo "Going to load RVM"

before

[[ -s "/Users/user/.rvm/scripts/rvm" ]] && source "/Users/user/.rvm/scripts/rvm"

in your ~/.bash_profile to see if it happens or not.



Related Topics



Leave a reply



Submit