安装了 rails 的新版本,无法识别 rails 命令
new version of rails installed, rails command not recognized
我想做一个新的 rails 应用程序。我安装了 ruby 2.4.4 因为我克隆了一个项目。
我曾经为项目设置过新版本
rbenv shell 2.4.4
因为 rbenv local 不工作
现在我正在使用 ruby 2.4.4
system
2.3.4
2.3.5
* 2.4.4 (set by RBENV_VERSION environment variable)
我收到以下错误消息:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.3.4
2.3.5
1) 我该如何解决这个问题?
2) 为什么 rbenv local 不工作?
当运行 rbenv local 2.4.4
时会发生什么
~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup rbenv local 2.4.4
~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
基本上什么都没发生。 Ruby 版本 2.3.5 仍处于选中状态。我希望在 运行 rbenv local 2.4.4 之后看到版本 2.4.4 被选中。我想这是我的 ENV 的问题,我在文件中编写的版本需要首选项,但我不知道如何解决这个问题。
在我的 .zshrc 中我有:
export RBENV_VERSION=2.3.5 # use rbenv rehash
export ALBERT=8
export PATH="$HOME/.rbenv/bin:$PATH:./node_modules/.bin"
那里的ruby版本是不是错了?我的路径正确吗?
因此,rbenv local 2.4.4 将永远不会因为 export RBENV_VERSION 被应用,对吗?
At a high level, rbenv intercepts Ruby commands using shim executables injected into your PATH, determines which Ruby version has been specified by your application, and passes your commands along to the correct Ruby installation.
When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon: /usr/local/bin:/usr/bin:/bin
Once rbenv has determined which version of Ruby your application has specified, it passes the command along to the corresponding Ruby installation.
Each Ruby version is installed into its own directory under ~/.rbenv/versions. For example, you might have these versions installed: ~/.rbenv/versions/1.8.7-p371/
因此,对于每个 ruby 版本,您必须安装两个 gem:
gem install bundler
gem install rails
关于如何修复 rbenv
您可以阅读 this question。
我想做一个新的 rails 应用程序。我安装了 ruby 2.4.4 因为我克隆了一个项目。
我曾经为项目设置过新版本
rbenv shell 2.4.4
因为 rbenv local 不工作
现在我正在使用 ruby 2.4.4
system
2.3.4
2.3.5
* 2.4.4 (set by RBENV_VERSION environment variable)
我收到以下错误消息:
rbenv: rails: command not found
The `rails' command exists in these Ruby versions:
2.3.4
2.3.5
1) 我该如何解决这个问题? 2) 为什么 rbenv local 不工作?
当运行 rbenv local 2.4.4
时会发生什么 ~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup rbenv local 2.4.4
~/Local_Documents/CodingArea/personal_projects/zaina-project/zaina_deal_room/zaina-dealroom setup ruby -v
ruby 2.3.5p376 (2017-09-14 revision 59905) [x86_64-darwin16]
基本上什么都没发生。 Ruby 版本 2.3.5 仍处于选中状态。我希望在 运行 rbenv local 2.4.4 之后看到版本 2.4.4 被选中。我想这是我的 ENV 的问题,我在文件中编写的版本需要首选项,但我不知道如何解决这个问题。
在我的 .zshrc 中我有:
export RBENV_VERSION=2.3.5 # use rbenv rehash
export ALBERT=8
export PATH="$HOME/.rbenv/bin:$PATH:./node_modules/.bin"
那里的ruby版本是不是错了?我的路径正确吗? 因此,rbenv local 2.4.4 将永远不会因为 export RBENV_VERSION 被应用,对吗?
At a high level, rbenv intercepts Ruby commands using shim executables injected into your PATH, determines which Ruby version has been specified by your application, and passes your commands along to the correct Ruby installation.
When you run a command like ruby or rake, your operating system searches through a list of directories to find an executable file with that name. This list of directories lives in an environment variable called PATH, with each directory in the list separated by a colon:
/usr/local/bin:/usr/bin:/bin
Once rbenv has determined which version of Ruby your application has specified, it passes the command along to the corresponding Ruby installation.
Each Ruby version is installed into its own directory under ~/.rbenv/versions. For example, you might have these versions installed:
~/.rbenv/versions/1.8.7-p371/
因此,对于每个 ruby 版本,您必须安装两个 gem:
gem install bundler
gem install rails
关于如何修复 rbenv
您可以阅读 this question。