Search code examples
rubybashshellrvmiterm2

iTerm2 Setup as Login Shell, RVM Still Gives Error


I have been trying to install Ruby-2.6.1 on my Macbook Pro for a couple of days now, and I have followed many posts and blog posts to try to get the setup correct, but I am not successful. I always get the following when trying to set the default Ruby with RVM:

picklemac:~ jblanchard$ rvm use default ruby-2.6.1

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.

I have followed the link, but with no success. I have iTerm2 setup as a login shell:

iterm2 login shell selected

In .bashrc I have the following:

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

And in .bash_profile I have the following:

# rvm
# export PATH="/Users/jblanchard/.rvm/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"

As I said, I have read and tried a number of things to get iTerm2 and my Mac setup properly, including How to make zsh run as a login shell on Mac OS X (in iTerm)?. Also, because I am trying to upgrade from Ruby 2.3 I have read a number of posts on just how to do that - again with no success.

What am I doing wrong?

Additional Info

I am able to successfully list the installations using rvm list:

picklemac:~ jblanchard$ rvm list
   ruby-2.6.0 [ x86_64 ]
=* ruby-2.6.1 [ x86_64 ]

# => - current
# =* - current && default
#  * - default

This is interesting, because RVM indicates Ruby-2.6.1 is the default, but when I use ruby -v the return is:

ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin17]


Solution

  • I was able to successfully make the change to Ruby-2.6.1. First, I uncommented the export line in .bash_profile:

    # rvm
    export PATH="/Users/jblanchard/.rvm/bin:$PATH" #UNCOMMENTED
    [[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
    

    After stopping and starting iTerm2 I issued the command to use Ruby-2.6.1 and received a warning, but then:

    picklemac:~ jblanchard$ rvm use default ruby-2.6.1
    Warning! PATH is not properly set up, /Users/jblanchard/.rvm/gems/ruby-2.6.1/bin is not at first place.
             Usually this is caused by shell initialization files. Search for PATH=... entries.
             You can also re-add RVM to your profile by running: rvm get stable --auto-dotfiles
             To fix it temporarily in this shell session run: rvm use ruby-2.6.1
             To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.
    Using /Users/jblanchard/.rvm/gems/ruby-2.6.1
    

    The change to Ruby-2.6.1 was made. It appears I do need to run rvm get stable --auto-dotfiles to fix the warning, which I would prefer to silencing it. Now, when running ruby -v the return is:

    ruby 2.6.1p33 (2019-01-30 revision 66950) [x86_64-darwin17]