Why Rvm Needs Login Shell

iTerm2 Setup as Login Shell, RVM Still Gives Error

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]

In login shell but rvm is not a function

I was sourcing the ~/.rvm/bin/rvm script twice. In the process of uninstalling and reinstalling, it once happened to not modify ~/.bash_profile. I then did this manually. A second uninstall/re-install dance then produced a ~/.bash_profile of:

source ~/.bashrc

# (lines added by me)
if [ -f /ubuntu/.rvm/bin/rvm ]; then
source '/ubuntu/.rvm/bin/rvm' > /dev/null
fi

# (lines added by RVM installer using: curl -L https://get.rvm.io | bash -s stable --auto-dotfiles)
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

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.

I'm getting RVM is not a function error on Mac OS X, and no posted solutions work

The solution ended up being on the RVM Help & Support page, in the ".bash_profile not being loaded on OSX" section. It seems that the issue was that I had my terminal set to open with the "default login shell" and when I changed it to instead open with the command "/usr/bash" in Preferences/Setup, "source ~/.rvm/scripts/rvm" started working, and rvm is now being recognized as a function.

RVM is not a function, selecting rubies with 'rvm use ...' will not work

Your console is not running as a login shell and hence have no access to rvm function. If you are running Ubuntu, you can:

  1. Open console
  2. Select Edit -> Profile Preferences
  3. Select tab: Title and Command
  4. Check box 'Run command as a login shell'
  5. Restart terminal


Related Topics



Leave a reply



Submit