Hi, recently I uninstalled RVM from my system in favor of Rbenv.
Apperently uninstalled all my gems like Rails and Rspec
So I reïnstalled them. However now I’m having an issue with Rspec when I run the test in my Rails project:
/Users/acandael/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rspec-core 3.0.3, but your Gemfile requires rspec-core 2.14.8. Prepending `bundle exec` to your command may solve this. (Gem::LoadError)
I can run my test, but I have to prepend it with ‘bundle exec’:
bundle exec rspec
Is there a way to solve this issue, so I can run my test again by simply typing:
Hi @acandael_acanda, I usually just use bundle exec aliased to be. You can however use rbenv-gemsets so that you use gems on per project basis. There are probably other ways to achieve this though.
You might also want to check that you have a binstub for rspec and that when you type which rspec from your app’s root that you get the binstub (meaning it’s in the proper location in your path). You shouldn’t have to be using bundle exec very often with a modern Rails app for things like rspec and rake with proper binstubs.
@acandael_acanda, the commands @croaky pasted should be used exactly as they are, there’s nothing to replace.
The dots tell your shell that for any original folder that has a subfolder with .git/safe in it, that the bin folder located in the original folder (two folders above safe, which is back where you started) should be in your path.
The reason this approach works is that it’s not possible to put things into the .git folder of a repository that get stored as repository contents, so if you were to download a git repository from someone else, that repo could only be declared as “trusted” by you adding safe to the .git folder.
BTW, it’s important that safe is a folder and not a file, or else the entry won’t be valid in your path and your shell will ignore it.
how odd, all of a sudden, after all was working fine, I get the same error again when trying to do run my testsuite with ‘rspec’:
/Users/acandael/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/bundler-1.6.5/lib/bundler/runtime.rb:34:in `block in setup': You have already activated rspec-core 3.0.3, but your Gemfile requires rspec-core 2.14.8. Prepending `bundle exec` to your command may solve this. (Gem::LoadError
to fix this I ran this command again:
bundle binstub rspec-core
but then I get the message
Skipped autospec and rspec since they already exist.
OK, it looks like you need to go back and try to implement the edits to .zshrc or .zshrc.local that @croaky described above. The two things you need to fix are:
Check that no further path editing statements prevent .git/safe/../../bin:$PATH from ending up at the front of your path. Rbenv loading will modify the path (by inserting its shims in the front), so do that before you try to add the git safe entry to the path.
Make sure that you have a safe folder in your app’s .git folder. It has to be a folder, it can’t be a file.
If those two items are corrected, and you have an rspec binstub in your binstubs folder, you should get the binstub as the result of which rspec.