Ruby 1.9.2 Rails 3.1
Here is the problem bundle exec rspec spec/
does not work, but rspec spec/
runs ok.
When I run c:\RailsInstaller\work\apptwit>bundle exec rspec spec/
(this is the directory where my app is located, so the path to spec would not need to be specified)
I receive
c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `require': no such file to load -- spec_he lper (LoadError)
from c:/RailsInstaller/work/apptwit/spec/controllers/pages_controller_spec.rb:1:in `<top (required)>'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `block in load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `map'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/configuration.rb:459:i
n `load_spec_files'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/command_line.rb:18:in
`run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:80:in `run_i
n_process'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:69:in `run'
from C:/RailsInstaller/Ruby1.9.2/lib/ruby/gems/1.9.1/gems/rspec-core-2.7.1/lib/rspec/core/runner.rb:10:in `block
in autorun'
/spec directory exists as exists spec_helper.rb in it.
So basically I have 2 questions:
Why doesn't bundle exec rspec spec/
work while rspec spec/
has no problems?
What is the difference between those two commands?
Take a look at this answer. bundle exec
changes your $PATH
, or %PATH%
in case of Windows. As a result, by using bundle exec rspec
you're calling the RSpec's version which is specified in your Gemfile
. rspec
ran without Bundler executes the one in your $PATH
.
The error you see might be caused by the fact that the RSpec version in your $PATH
is incompatible with Rails version you're working with. The version installed and executed by Bundler (with bundle exec rspec
) is compatible and works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With