rbenv can't change global ruby version

后端 未结 7 1974
时光说笑
时光说笑 2021-02-02 13:11

My Mac OS X has a default ruby.

$ ruby -v
ruby 2.0.0p451 (2014-02-24 revision 45167) [universal.x86_64-darwin13]

I installed rbenv and ruby ver

相关标签:
7条回答
  • 2021-02-02 13:48

    Type $ rbenv version (without "s")

    It is possible that output will show a path to the file that is locking the version

    2.0.0p451 (set by /path/to/some/directory/.ruby-version)
    

    It is even possible that the file is a hidden file named .ruby-version in your current dir. If its the case just remove that .ruby-version file

    0 讨论(0)
  • 2021-02-02 13:49

    Did you add the following lines to your ~/.bash_profile?

    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"
    

    See: https://github.com/sstephenson/rbenv#installation

    0 讨论(0)
  • 2021-02-02 13:54

    I realize that I occasionally set local ruby version in home folder, from which I use terminal by default :) So that's what worked for me:

    rm /home/MYUSERNAME/.ruby-version
    
    0 讨论(0)
  • 2021-02-02 13:55

    I had the same issue ("ruby -v" showing the initial version) but reloading (exit/start) my terminal made the trick.

    Did you try that first?

    0 讨论(0)
  • 2021-02-02 13:59

    Uninstall ruby and then install agains:

    brew uninstall -f ruby
    brew install ruby
    

    Add this two line to you ~/.bash_profile

    export PATH="$HOME/.rbenv/bin:$PATH"
    eval "$(rbenv init -)"
    

    Reopen the console and that's it and run

    ruby -v 
    
    0 讨论(0)
  • 2021-02-02 13:59

    instead of:
    rbenv global 2.7.1
    do:
    sudo rbenv global 2.7.1

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