I have recently moved from RVM to Rbenv and when attempting to execute rails I am getting an error like the one below
我最近从RVM迁移到Rbenv,当我尝试执行rails时,我收到的错误如下所示
Pauls-Air:~ $ rails
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.1.2
3 个解决方案
#1
#2
7
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.
您需要在rbenv中为每个Ruby版本安装Rails。尝试运行rbenv版本,我可能期望2.1.2不是当前项目(本地版本)或您的全球版本使用的ruby版本。
#3
0
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.
我遇到了同样的问题,但这些其他解决方案(或我在别处找到的任何其他解决方案)都没有奏效。我准备回到RVM,所以我决定完全摆脱rbenv,它为解决方案铺平了道路。
Try the following - it worked for me:
尝试以下 - 它对我有用:
-
uninstalling rbenv, remove all references rbenv in your bash profile, and remove the remaining rbenv file folder and its contents.
卸载rbenv,删除bash配置文件中的所有引用rbenv,并删除剩余的rbenv文件文件夹及其内容。
-
Reinstall rbenv with homebrew.
用homebrew重新安装rbenv。
-
Add it back to your bash profile:
将其添加回您的bash配置文件:
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH" eval "$(rbenv init -)"
-
Restart the shell:
重启shell:
exec $SHELL -l
-
Check the path:
检查路径:
echo $PATH
-
Install Rails:
安装Rails:
gem install rails
-
rbenv rehash
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
注意:我为此答案的一部分咨询了这个:https://www.codementor.io/tips/3732499178/solution-for-rbenv-rails-is-not-currently-installed-on-this-system-to-get -the-最新版本 - 只需型
#1
30
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
在ruby版本中通过命令行安装gem之后,你必须执行rbenv rehash,如此处和此处的文档中所述
For example:
例如:
$ rbenv install 2.2.0
$ gem install bundler
$ rbenv rehash
$ gem install rails
$ rbenv rehash
#2
7
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.
您需要在rbenv中为每个Ruby版本安装Rails。尝试运行rbenv版本,我可能期望2.1.2不是当前项目(本地版本)或您的全球版本使用的ruby版本。
#3
0
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.
我遇到了同样的问题,但这些其他解决方案(或我在别处找到的任何其他解决方案)都没有奏效。我准备回到RVM,所以我决定完全摆脱rbenv,它为解决方案铺平了道路。
Try the following - it worked for me:
尝试以下 - 它对我有用:
-
uninstalling rbenv, remove all references rbenv in your bash profile, and remove the remaining rbenv file folder and its contents.
卸载rbenv,删除bash配置文件中的所有引用rbenv,并删除剩余的rbenv文件文件夹及其内容。
-
Reinstall rbenv with homebrew.
用homebrew重新安装rbenv。
-
Add it back to your bash profile:
将其添加回您的bash配置文件:
export PATH="$HOME/.rbenv/bin:/usr/local/bin:$PATH" eval "$(rbenv init -)"
-
Restart the shell:
重启shell:
exec $SHELL -l
-
Check the path:
检查路径:
echo $PATH
-
Install Rails:
安装Rails:
gem install rails
-
rbenv rehash
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
注意:我为此答案的一部分咨询了这个:https://www.codementor.io/tips/3732499178/solution-for-rbenv-rails-is-not-currently-installed-on-this-system-to-get -the-最新版本 - 只需型