rails rbenv: rails: command not found

╄→гoц情女王★ 提交于 2019-12-02 18:41:22

After installing a gem via the command line in a ruby version you have to execute rbenv rehash as described in the docs here and here

For example:

$ rbenv install 2.2.0
$ gem install bundler
$ rbenv rehash
$ gem install rails
$ rbenv rehash

You need to install Rails for each Ruby version within rbenv. Try running rbenv version, I might expect that 2.1.2 is not the ruby version in use for the current project (local version) or maybe your global version.

Bob

I ran into the same issue, but none of these other solutions (or any of the others I found elsewhere) worked. I was about to go back to RVM, so I decided to get rid of rbenv completely and it paved the way to the solution.

Try the following - it worked for me:

  1. uninstalling rbenv, remove all references rbenv in your bash profile, and remove the remaining rbenv file folder and its contents.

  2. Reinstall rbenv with homebrew.

  3. Add it back to your bash profile:

    export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH"
    eval "$(rbenv init -)"
    
  4. Restart the shell:

    exec $SHELL -l
    
  5. Check the path:

    echo $PATH
    
  6. Install Rails:

    gem install rails
    
  7. rbenv rehash

Note: I consulted this for part of this answer: https://www.codementor.io/tips/3732499178/solution-for-rbenv-rails-is-not-currently-installed-on-this-system-to-get-the-latest-version-simply-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!