rbenv: ruby: 命令未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21275951/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
rbenv: ruby: command not found
提问by Lawrence DeSouza
I am using rbenv with ruby version 1.9.1-p378 on the local dir.
我在本地目录上使用 rbenv 和 ruby 版本 1.9.1-p378。
Command ruby -vgives the following error:
命令ruby -v给出以下错误:
rbenv: ruby: command not found
The `ruby' command exists in these Ruby versions:
2.0.0-p353
Any clue why this happens? The bundle, rails commands do not work either.
任何线索为什么会发生这种情况?bundle, rails 命令也不起作用。
Command rbenv versions:
命令rbenv 版本:
* 1.9.1-p378 (set by /home/user/Desktop/r1/noko1/.ruby-version)
2.0.0-p353
回答by z5h
The complaint you get comes from rbenv. The fact that it's complaining shows that rbenv is set up and working.
Figure out what version of Ruby is needed to run the project. Either the project comes with a .ruby-version file in the root, or someone on the project will know and recommend that version to use.
If the version is not specified in a .ruby-version file, create the .ruby-version file in the project directory.
type
ruby -vwhile in that directory. Is it OK? Then you have the version of Ruby installed that matches what your .ruby-version is asking for.If the last command was not OK, then type
rbenv install.
您收到的投诉来自rbenv。它抱怨的事实表明 rbenv 已设置并正常工作。
确定运行项目所需的 Ruby 版本。项目的根目录中带有 .ruby-version 文件,或者项目中的某个人知道并推荐使用该版本。
如果 .ruby-version 文件中未指定版本,请在项目目录中创建 .ruby-version 文件。
ruby -v在该目录中键入。可以吗?然后您安装了与您的 .ruby-version 要求相匹配的 Ruby 版本。如果最后一个命令不正确,则键入
rbenv install。
Now that Ruby is installed, you need to run your program. I'm assuming it comes with a Rakefile.
现在安装了 Ruby,您需要运行您的程序。我假设它带有一个 Rakefile。
install the bundler tool:
gem install bundler.install the dependancies of the project:
bundle installrun your project using the exact versions of libraries it specifies:
bundle exec rails server
安装打包工具:
gem install bundler.安装项目的依赖项:
bundle install使用它指定的库的确切版本运行您的项目:
bundle exec rails server
回答by Thengugi
Try the following piece of code depending on the current version of rails that you have installed. In my case am using v2.3.3
根据您安装的当前版本的 rails 尝试以下代码。就我而言,我正在使用v2.3.3
rbenv global 2.3.3
回答by Conner
It seems you need to rbenv installthe ruby version you want to use, since only 2.0.0-p353is available. See rbenv help.
看来你需要rbenv install你想要使用的 ruby 版本,因为只有2.0.0-p353可用。见rbenv help。

