Ruby-on-rails 耙子:找不到命令

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1664974/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:55:08  来源:igfitidea点击:

rake: command not found

ruby-on-railsubunturake

提问by eksatx

I'm trying to install rails on Ubuntu 9.10.

我正在尝试在 Ubuntu 9.10 上安装 rails。

gem list --local

*** LOCAL GEMS ***

actionmailer (2.3.4, 2.3.2)
actionpack (2.3.4, 2.3.2)
activerecord (2.3.4, 2.3.2)
activeresource (2.3.4, 2.3.2)
activesupport (2.3.4, 2.3.2)
rack (1.0.1)
rails (2.3.4, 2.3.2)
rake (0.8.7)
sqlite3-ruby (1.2.5)

rake
The program 'rake' is currently not installed.  You can install it by typing:
sudo apt-get install rake
rake: command not found

How do I solve this?

我该如何解决这个问题?

回答by Siddhartha Reddy

You need to add /var/lib/gems/1.8/binto your PATH. Try this command:

您需要将/var/lib/gems/1.8/bin添加到您的PATH。试试这个命令:

export PATH=$PATH:$HOME/bin:/var/lib/gems/1.8/bin

After that rakeshould work.

在那个耙子应该工作之后。

You can add this line to your ~/.bashrc so that you don't have to type in this command each time.

您可以将此行添加到您的 ~/.bashrc 中,这样您就不必每次都输入此命令。

回答by Henryk Konsek

Gem is complaining about the rake program(i.e. executable), not the rake gem(you have the latter already installed).

Gem 抱怨的是 rake程序(即可执行程序),而不是 rake gem(您已经安装了后者)。

That means that you have to add rake exec to the PATH. Possible rake bin location is /var/lib/gems/1.8/bin/rake. Add it to your PATH then:

这意味着您必须将 rake exec 添加到 PATH。可能的耙子位置是/var/lib/gems/1.8/bin/rake。然后将其添加到您的 PATH 中:

export PATH=${PATH}:/var/lib/gems/1.8/bin

You can also install Rake from the Ubuntu repository (as suggested in the gem output):

您还可以从 Ubuntu 存储库安装 Rake(如 gem 输出中所建议):

sudo apt-get install rake

回答by anotherdjohnson

They are correct, you need to have rake in your path. However if you want to make sure it's just there, instead of exporting it from .bashrc, make a symbolic link:

他们是正确的,你需要在你的道路上有耙子。但是,如果您想确保它就在那里,而不是从 .bashrc 导出它,请创建一个符号链接:

sudo ln -s /var/lib/gems/1.8/bin/rake /usr/bin/rake

sudo ln -s /var/lib/gems/1.8/bin/rake /usr/bin/rake

If you do that, you should always be able to use it.

如果你这样做,你应该总是能够使用它。

回答by lucapette

The solution, at least for me, is making the symbolic link.

至少对我来说,解决方案是建立符号链接。

This is the kind of issue I have to remember. Every time I set a new Ubuntu machine I run into this little problem.

这是我必须记住的问题。每次我设置一台新的 Ubuntu 机器时,我都会遇到这个小问题。

回答by sumpfgottheit

I ran into the same problem on Centos 5.5 and self compiled ruby and rails. (Need it for redmine) When i tried to install passenger using passenger-install-apache2-module, I did an strace and round out, that passenger looks for rake in the ruby/bindirectory and not the gems/bindirectory, where rake was installed. So a

我在 Centos 5.5 和自编译 ruby​​ 和 rails 上遇到了同样的问题。(redmine需要它)当我尝试使用passenger-install-apache2-module安装乘客时,我做了一个strace并完成了,那个乘客在ruby/bin目录而不是gems/bin目录中寻找rake ,其中rake已安装。所以一个

ln -s /usr/local/ruby1.8.7/lib/ruby/gems/1.8/bin/rake /usr/local/ruby1.8.7/bin

solved it for me. (/usr/local/ruby1.8.7 is where i installed ruby...)

为我解决了。(/usr/local/ruby1.8.7 是我安装 ruby​​ 的地方...)