bundler:无法加载命令:rspec

问题描述 投票:0回答:1

我是 Rails 新手,我想使用 Mac 运行 Rspec。

当我跑步时:

bundle exec rspec spec/00_hello_spec.rb 

我收到以下回复:

bundler: failed to load command: rspec (/Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/bin/rspec)
LoadError: cannot load such file -- spec_helper
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181:in `require'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181:in `block in requires='
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181:in `each'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration.rb:1181:in `requires='
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:110:in `block in process_options_into'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:109:in `each'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:109:in `process_options_into'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/configuration_options.rb:22:in `configure'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:96:in `setup'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:85:in `run'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:70:in `run'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/lib/rspec/core/runner.rb:38:in `invoke'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/gems/rspec-core-3.2.3/exe/rspec:4:in `<top (required)>'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/bin/rspec:22:in `load'
  /Users/OumouKaba/Downloads/test-first-ruby-master/vendor/bundle/ruby/2.4.0/bin/rspec:22:in `<top (required)>'

请帮助提供有关此问题的任何建议或澄清。要补充的是,我已经在文件系统的各个级别(从根向上)完成了此操作。我非常感谢任何帮助我摆脱困境的澄清。

ruby rspec
1个回答
0
投票

如果将来有人遇到此问题,请尝试查看是否安装了不同版本的 rspec gems,如下所示:

gem list | grep rspec

如果这样做,请删除与您的 Gemfile.lock 中的版本不匹配的 gem 版本,如下所示:

gem uninstall <gem_name> <gem_version>

按照这些步骤后,我能够成功运行

rspec spec

© www.soinside.com 2019 - 2024. All rights reserved.