无法生成 rails 命令:bundle exec rspec spec/requests

Posted

技术标签:

【中文标题】无法生成 rails 命令:bundle exec rspec spec/requests【英文标题】:Cannot generate rails command: bundle exec rspec spec/requests 【发布时间】:2013-11-15 06:40:45 【问题描述】:

我正在尝试启动第二个 Rails 项目,而对于我的第一个项目,rspec 运行良好。我复制了 Gemfile 以获得相同的 gem,并且我的项目文件中有 spec/requests 目录。但是,当我尝试执行时出现此错误

C:\Sites\rails_projects\friendapp\app\views\static_pages>bundle exec rspec spec/ 要求 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.11.1/lib/rspec /core/configuration.rb:780:in load': cannot load such file -- C:/Sites/rails_pr ojects/friendapp/app/views/static_pages/spec/requests (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/configuration.rb:780:inblock in load_spec_files' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/configuration.rb:780:in map' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/configuration.rb:780:inload_spec_files' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/command_line.rb:22:in run' from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/runner.rb:69:inrun' 来自 C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rspec-core-2.1 1.1/lib/rspec/core/runner.rb:8:in `block in autorun'

有什么线索吗?谢谢!

【问题讨论】:

您是否在新项目中运行了bundle install 【参考方案1】:

您似乎不是从应用的根目录执行 bundle exec,而是从 app\views\static_pages:

C:\Sites\rails_projects\friendapp\app\views\static_pages>

错误消息表明该位置不存在该文件 (static_pages):

C:/Sites/rails_projects/friendapp/app/views/static_pages/spec/requests

切换到根目录并重试

C:\Sites\rails_projects\friendapp\>bundle exec rspec spec/requests 

【讨论】:

以上是关于无法生成 rails 命令:bundle exec rspec spec/requests的主要内容,如果未能解决你的问题,请参考以下文章

Ruby bundle exec

$ bundle exec rake db:reset 命令提升无法删除 db/development.sqlite3

使用 bundle exec rake 还是只使用 rake?

我想设置话语,但是我遇到了这个错误。当我在窗口powershell中运行'bundle exec rails s -b 0.0.0.0'时,它会告诉我这个

bundle exec rake assets:预编译失败,出现“意外令牌”

我无法使用 'bundle exec rspec' 执行 rspec