命令未找到/使用autotest安装缺失的gem二进制文件'bundle install'

9

我完全不了解RoR。我正在跟随Michael Hartl的书学习。我无法使autotest运行。请建议出错原因并提供解决方案。

当我在Rails项目目录中的命令行中运行'autotest'时,我得到以下结果:

-bash: autotest: command not found

当我运行'bundle exec autotest'时,会得到以下结果:
 bundler: command not found: autotest
 Install missing gem binaries with `bundle install'

这是Gemfile文件

source 'http://rubygems.org'

gem 'rails', '3.0.3'
gem 'sqlite3-ruby', :require => 'sqlite3'

group :development do
gem 'autotest'
gem 'rspec-rails', '2.4.1' 
end

group :test do
gem 'rspec', '2.4.0'
gem 'webrat', '0.7.1'
end

这是从 'gem list' 命令得到的输出结果。
abstract (1.0.0)
actionmailer (3.0.7, 3.0.6, 3.0.3, 2.3.5, 1.3.6)
actionpack (3.0.7, 3.0.6, 3.0.3, 2.3.5, 1.13.6)
actionwebservice (1.2.6)
activeresource (3.0.7, 3.0.6, 3.0.3, 2.3.5)
activesupport (3.0.7, 3.0.6, 3.0.3, 2.3.5, 1.4.4)
acts_as_ferret (0.4.3)
arel (2.0.9)
autotest (4.4.6)
autotest-fsevent (0.2.5)
autotest-growl (0.2.9)
autotest-notification (2.3.1)
autotest-rails-pure (4.1.2)
builder (2.1.2)
bundler (1.0.12)
capistrano (2.5.2)
cgi_multipart_eof_fix (2.5.0)
configuration (1.2.0)
daemons (1.0.10)
diff-lcs (1.1.2)
dnssd (0.6.0)
erubis (2.6.6) 
fastthread (1.0.1)
fcgi (0.8.7)
ferret (0.11.6)
gem_plugin (0.2.3)
heroku (2.0.4)
highline (1.5.0)
hpricot (0.6.164)
i18n (0.5.0)
launchy (0.4.0)
libxml-ruby (1.1.2)
mail (2.2.19, 2.2.15) 
mime-types (1.16)
mongrel (1.1.5)
mysql2 (0.2.7)
needle (1.3.0)
net-scp (1.0.1)
net-sftp (2.0.1, 1.1.1)
net-ssh (2.0.4, 1.1.4)
net-ssh-gateway (1.0.0)
nokogiri (1.4.4)
notifier (0.1.3)
polyglot (0.3.1)
rack (1.2.2, 1.0.1)
rack-mount (0.6.14)
rack-test (0.5.7)
rails (3.0.7, 3.0.6, 3.0.3, 2.3.5, 1.2.6)
railties (3.0.7, 3.0.6, 3.0.3)
rake (0.8.7, 0.8.3)
RedCloth (4.1.1)
redgreen (1.2.2)
rest-client (1.6.1)
rspec (2.5.0, 2.4.0)
rspec-core (2.5.1, 2.4.0) 
rspec-expectations (2.5.0, 2.4.0)
rspec-mocks (2.5.0, 2.4.0)
rspec-rails (2.5.0, 2.4.1)
ruby-openid (2.1.2)
ruby-yadis (0.3.4)
rubygems-update (1.7.2)
rubynode (0.1.5)
spork (0.8.4)
sqlite3-ruby (1.3.2, 1.2.5, 1.2.4)
sys-uname (0.8.5)
term-ansicolor (1.0.5)
termios (0.9.4)
test_notifier (0.3.6)
thor (0.14.6)
treetop (1.4.9)
tzinfo (0.3.27, 0.3.26)
webrat (0.7.1)
xmpp4r (0.4)
ZenTest (4.5.0)

1
那么,你尝试运行 bundle install 了吗? - Sergey Kishenin
是的,"bundle install" 没问题,但是 autotest 不起作用。 - aspire
这可能不是你的问题,但我见过许多情况,在Windows上使用Bundler时二进制文件没有正确安装。我不得不手动卸载gem并手动安装。环境:Windows 7、jruby 1.6.2、Bundler、Rails3+。 - user1229231
6个回答

8

bundle install --binstubs将安装来自您的bundle的所有可执行文件到本地bin目录中(请参见http://gembundler.com/),然后您可以运行./bin/autotest


你可以尝试使用RVM——从全局gemset中删除ZenTest/autotest,而是安装到基于rvm的gemset中,看看是否有所帮助。 - Keith Gaddis
我在这里迷失了。你能告诉我如何进行基于rvm的gemset安装吗?谢谢。 - aspire
首先,你需要安装RVM:https://rvm.beginrescueend.com/然后就是创建并切换到另一个gemset,用于使用你想要的ruby版本,例如1.9.2:'rvm use 1.9.2 && rvm gemset create mygemset && rvm use 1.9.2@mygemset' - Keith Gaddis
我们可以按照这里的建议,将宝石的bin文件夹添加到路径中,而不是将可执行文件复制到本地目录。-http://stackoverflow.com/questions/3766491/autotest-with-rspec2-in-rails-3-cant-find-binaries - Kalarani

7

只需重新启动终端标签页并重试即可。这样应该就能解决问题了。


3
我遇到了类似的错误。
bundler: command not found: thin
Install missing gem executables with `bundle install`

运行以下命令即可添加需要的 gem:

bundle install --deployment


1
关于这个答案的更新 - 目前使用 --deployment 标志会导致以下错误: “--deployment 标志已弃用,因为它依赖于在 bundler 调用之间被记住,而在未来的版本中 bundler 将不再这样做。请改用 bundle config set deployment 'true',并停止使用此标志”。因此,新命令是 bundle config set deployment 'true' - Rick Gladwin

0

请确保将autotest命令放在测试块中。您似乎只将其放在开发块中。然后,执行bundle install命令。


0

对于 rvm 的用户:

$ rvm gemset create myapp
$ bundle install

对我有用。


-3
我曾经遇到过同样的问题,但我按照以下步骤并下载了mysql。这个链接告诉你如何做。 mysql 现在我有一个重置密码的问题,但一旦打开第二个下载文件,你就需要输入临时密码,然后它会要求你更改密码。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接