Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialAlex Bishop
4,817 PointsCannot run "bin/rails generate rspec:install" (LoadError). Kinda lost on how to deal with this
Hey Treehouse,
So I was following along with the video on Setting up Git and adding Gems for ODOT but I seem to run into a wall. When trying to run the command "bin/rails generate rspec:install", after adding rspec and capybara to the Gemfile and running bundle, I run into this error:
Alexs-iMac:odot DarkSteel$ bin/rails generate rspec:install
/Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/DarkSteel/Desktop/Coding/Treehouse_coding/Treehouse_ruby/ODOT/odot/config/boot.rb:4:in `<top (required)>'
from bin/rails:7:in `require_relative'
from bin/rails:7:in `<main>'
I'm still new to ruby and this is the first time I have even tried anything with an application or gems, can someone help me out and explain to me why I have run into this error and how to make the command for generating the rspec install to go through? Thanks!
Alex
Alex Bishop
4,817 PointsTried doing that, got the following errors:
Alexs-iMac:odot DarkSteel$ spring stop
/Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:298:in `to_specs': Could not find 'spring' (>= 0) among 9 total gem(s) (Gem::LoadError)
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/dependency.rb:309:in `to_spec'
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:53:in `gem'
from /usr/bin/spring:22:in `<main>'
Alexs-iMac:odot DarkSteel$ rails generate rspec:install
Warning: You're using Rubygems 2.0.14 with Spring. Upgrade to at least Rubygems 2.1.0 and run `gem pristine --all` for better startup performance.
/Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- bundler/setup (LoadError)
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/commands.rb:33:in `<module:Spring>'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/commands.rb:4:in `<top (required)>'
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application.rb:77:in `preload'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application.rb:143:in `serve'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application.rb:131:in `block in run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application.rb:125:in `loop'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application.rb:125:in `run'
from /Library/Ruby/Gems/2.0.0/gems/spring-1.2.0/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/DarkSteel/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
Jeff Jacobson-Swartfager
15,419 PointsCheck your Gemfile to make sure you've got everything you need. According to this issue it looks like it could be that you're missing some dependencies.
Could you post your Gemfile?
Alex Bishop
4,817 PointsOkay! Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.1.5'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
group :development, :test do
gem 'rspec-rails', '~> 2.0'
end
group :test do
gem 'capybara', '~>2.1.00'
end
1 Answer
Jeff Jacobson-Swartfager
15,419 PointsAlright, I just ran a fresh install using your Gemfile but I'm not getting any errors.
I did notice a couple of differences between your Gemfile and the one that is used in the video though. The video's Gemfile looks like this:
gem 'rails', '4.0.1'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~>4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
group :development, :test do
gem 'rspec-rails', '~> 2.0'
end
group :test do
gem 'capybara', '~> 2.1.0'
end
Also, I noticed that you are using rbenv. My experience with that is not as extensive as my experience with rvm, but I am aware that it doesn't use the same concept of gemsets. I've found that gemsets are really nice in that they greatly reduce conflicts between multiple versions of the same gem.
Try running gem list
to make sure you don't have multiple versions of the same gem.
Jeff Jacobson-Swartfager
15,419 PointsIt also looks like you'll need to run rbenv rehash
after each time you run bundle
. See this stackoverflow answer for details.
Alex Bishop
4,817 PointsOkay, here is what I got when I ran that:
*** LOCAL GEMS ***
awesome_print (1.2.0)
bigdecimal (1.2.4)
io-console (0.4.2)
json (1.8.1)
minitest (4.7.5)
psych (2.0.5)
rake (10.1.0)
rdoc (4.1.0)
test-unit (2.1.2.0)
Doesn't seem to be any repeats. I tried running the generate command again with no luck. Should I just try overwriting my whole gemfile?
Jeff Jacobson-Swartfager
15,419 PointsI'd hold back on overwriting your Gemfile for now (although you could save it with a different name temporarily before creating a new one, say... Gemfile.bak
).
Run this:
rbenv rehash
Also, you might not be using the ruby you think you're using. Check which ruby you're using with this:
ruby -v
And if it isn't the right ruby, switch to the appropriate one with this (replace with your ruby):
rbenv local MYRUBYHERE
You'll need to bundle install
and rbenv rehash
again after doing this.
Alex Bishop
4,817 PointsI get this when I run rbenv rehash
rbenv: cannot rehash: /Users/DarkSteel/.rbenv/shims isn't writable
I'm running it from the exact directory of the project. Anything I could be doing wrong? I do all the other steps fine, my ruby version checks out, but this won't rehash. I'm still getting the same errors when trying to generate rspec:install.
Jeff Jacobson-Swartfager
15,419 PointsThat's definitely an indication of what might be going on. You'll need to be able to write to that file in order to rehash. As to what the ultimate source of the issue is, I'm unsure.
Try the following to make the shims folder writeable:
chmod a+w /Users/DarkSteel/.rbenv/shims
This will change permissions so that all users, groups, and others can write to this folder. If that makes you nervous, you could try chmod ug+w /Users/DarkSteel/.rbenv/shims
instead (this will give just users and groups write permission).
You may need to sudo
to do this.
Alex Bishop
4,817 PointsOkay, so that allowed me to run the rbenv rehash command but I still have had no luck getting my original command bin/rails generate rspec:install to run, even after rerunning bundle install and then running rbenv rehash. The same error is showing up :/
Jeff Jacobson-Swartfager
15,419 PointsHave you switched to the right ruby? See this comment.
Alex Bishop
4,817 PointsYeah, did that and I just tried again, no luck. Sorry for not mentioning it.
Jeff Jacobson-Swartfager
15,419 PointsJeff Jacobson-Swartfager
15,419 PointsIt looks like you should try stoping and restarting spring.
Link to a previous question on this.