“RVM is not a function” error

后端 未结 10 1775
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 22:22

RVM is installed on my machine (running Mac OSX 10.6.8), correctly and it runs fine. The odd thing is that to run it, I have to use source ~/.rvm/scripts/rvm for ev

相关标签:
10条回答
  • 2021-01-30 22:35

    If you are using zsh as shell instead bash, you have to:

    1.

    vi ~/.zshrc 
    

    2. Like Matt said, add:

    if test -f ~/.rvm/scripts/rvm; then
       [ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
    fi
    

    3. Restart Terminall 4. Done!

    rvm use 1.9.3
    

    Wil work

    0 讨论(0)
  • 2021-01-30 22:35

    Well, with mountain lion (10.8.3) what worked for me was editing /etc/profile

    and adding the line mentioned before at the bottom of the file:

      if test -f ~/.rvm/scripts/rvm; then
            [ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
        fi
    
    0 讨论(0)
  • 2021-01-30 22:36

    You have to source the RVM script into the current session because it makes changes to the shell environment - and it is absolutely impossible for that to be done from a child process. Your efforts at running RVM as an external command cannot succeed.

    To actually fix this you have two choices:

    1. Configure your terminal emulator to start a login shell, rather than a non-login shell, so that your .profile is loaded.
    2. Modify .bashrc to source RVM instead, which works for non-login shells as well.

    To do the second you can just add to ~/.bashrc:

    if test -f ~/.rvm/scripts/rvm; then
        [ "$(type -t rvm)" = "function" ] || source ~/.rvm/scripts/rvm
    fi
    
    0 讨论(0)
  • 2021-01-30 22:37

    I had this issue when I became root. I tried many of the solutions above. What finally worked was exiting from root and being a regular user. Which is what I needed anyway.

    0 讨论(0)
  • 2021-01-30 22:42

    I didn't understand what ~/.profile does correctly; I needed to change ~/.bash_profile instead. Problem solved!

    0 讨论(0)
  • 2021-01-30 22:42

    You have to make some settings.

    Open terminal and run this command.

    source ~/.rvm/scripts/rvm
    

    and then go to edit > Title and command and check Run command as login shell

    and you are done. Now you don't need to specify source everytime.

    0 讨论(0)
提交回复
热议问题