Bundler找不到rspec可执行文件

时间:2018-01-02 23:47:58

标签: ruby-on-rails ruby rspec bundler

当我尝试在我的Rails 5.1应用程序中运行测试时,我收到一条错误,指出找不到可执行文件:

$ bundle exec rspec
bundler: failed to load command: rspec (/Users/joepalmieri/.rbenv/versions/2.3.3/bin/rspec)
Gem::Exception: can't find executable rspec
  /Users/joepalmieri/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/rubygems_integration.rb:408:in `block in replace_bin_path'
  /Users/joepalmieri/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/bundler-1.14.6/lib/bundler/rubygems_integration.rb:434:in `block in replace_bin_path'
  /Users/joepalmieri/.rbenv/versions/2.3.3/bin/rspec:22:in `<top (required)>'

然而,当我查看/Users/joepalmieri/.rbenv/versions/2.3.3/bin时,可执行文件就在那里:

$ ls /Users/joepalmieri/.rbenv/versions/2.3.3/bin | grep rspec
// => rspec

以下是我的Gemfile的相关部分:

gem 'rails', '~> 5.1.4'

group :development, :test do
  gem 'rspec-rails', '3.7.2'
end

正在运行rbenv rehash没有帮助。

关于这个愚蠢的事情的任何线索我都是为了制造这种疯狂吗?

1 个答案:

答案 0 :(得分:3)

当然这很明显。我在本地运行bundle install --without development test来测试一些东西。我没有意识到在此之后运行bundle install(不合格)将重复安装相同的组(即,它不会为development和{{1安装宝石}}。)。

正在运行test修复此问题。