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 trialkabir k
Courses Plus Student 18,036 PointsGot a different error message after running `bin/rake` command in the terminal
I got the following error message after running bin/rake
command in the terminal, which is different from what Jason has on the Using has_secure_password
video at 2:47
Can someone figure out what the problem is and how to fix it, thanks.
treehouse:~/projects/odot (master *) $ bin/rake
/home/treehouse/.rbenv/versions/2.0.0-p353/bin/ruby -I/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib:/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-support-3.0.4/lib -S /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/controllers/todo_lists_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/features/todo_items/complete_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/delete_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/helpers/users_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/models/user_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/routing/users_routing_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb ./spec/views/users/edit.html.erb_spec.rb ./spec/views/users/new.html.erb_spec.rb ./spec/views/users/show.html.erb_spec.rb
/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in require': cannot load such file -- rails_helper (LoadError)
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in
block in require'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in load_dependency'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:229:in
require'
from /home/treehouse/projects/odot/spec/controllers/users_controller_spec.rb:1:in <top (required)>'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in
load'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in block in load'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:214:in
load_dependency'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/activesupport-4.0.1/lib/active_support/dependencies.rb:223:in load'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in
block in load_spec_files'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in each'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/configuration.rb:1058:in
load_spec_files'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:97:in setup'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:85:in
run'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:70:in run'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib/rspec/core/runner.rb:38:in
invoke'
from /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/exe/rspec:4:in `<main>'
/home/treehouse/.rbenv/versions/2.0.0-p353/bin/ruby -I/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/lib:/home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-support-3.0.4/lib -S /home/treehouse/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/rspec-core-3.0.4/exe/rspec ./spec/controllers/todo_items_controller_spec.rb ./spec/controllers/todo_lists_controller_spec.rb ./spec/controllers/users_controller_spec.rb ./spec/features/todo_items/complete_spec.rb ./spec/features/todo_items/create_spec.rb ./spec/features/todo_items/delete_spec.rb ./spec/features/todo_items/edit_spec.rb ./spec/features/todo_items/index_spec.rb ./spec/features/todo_lists/create_spec.rb ./spec/features/todo_lists/destroy_spec.rb ./spec/features/todo_lists/edit_spec.rb ./spec/helpers/todo_items_helper_spec.rb ./spec/helpers/todo_lists_helper_spec.rb ./spec/helpers/users_helper_spec.rb ./spec/models/todo_item_spec.rb ./spec/models/todo_list_spec.rb ./spec/models/user_spec.rb ./spec/requests/todo_lists_spec.rb ./spec/routing/todo_lists_routing_spec.rb ./spec/routing/users_routing_spec.rb ./spec/views/todo_items/index.html.erb_spec.rb ./spec/views/todo_lists/edit.html.erb_spec.rb ./spec/views/todo_lists/index.html.erb_spec.rb ./spec/views/todo_lists/new.html.erb_spec.rb ./spec/views/todo_lists/show.html.erb_spec.rb ./spec/views/users/edit.html.erb_spec.rb ./spec/views/users/new.html.erb_spec.rb ./spec/views/users/show.html.erb_spec.rb failed
treehouse:~/projects/odot (master *) $
1 Answer
Seth Reece
32,867 PointsHi Kabir,
The error you are getting is "cannot load such file -- rails_helper". What version of rspec are you using in your gem file? If you are using rspec 3, you want to require rails_helper instead of spec_helper in all you spec files. All custom configuration also goes into rails_helper instead of spec_helper. If you are using rspec 2, then there is only a spec_helper, and no rails_helper. In this case make sure all your spec files require spec_helper and not rails_helper.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsHi Seth,
Thanks for your response. I believe I'm using version 3. Here's my Gemfile:
Do I have to manually require rails_helper instead of spec_helper in all my spec files or there's an automated way to do that. And when I'm done with the changes do I run bundle install as well?
Also, what do you mean by "All custom configuration also goes into rails_helper instead of spec_helper"?
Seth Reece
32,867 PointsSeth Reece
32,867 PointsIf you don't have 'rails_helper.rb' in your spec folder, try changing the rspec-rails gem to 2.0, then bundle. (This would be the easiest option.) If you want to use 3.0, see if running rails generate rspec:install creates a rails_helper in your spec folder. If it does, then you will want to put require 'rails_helper' at the top of all your spec files. If you have any requires in spec_helper, like require 'rspec-rails' you will want them in rails_helper.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsHey Seth, thanks a lot. I see I have two options now and sorry to be such a pain but I don't really get the last sentence of your response. Can you give me an example of what to do here?
Also, after changing to 2.0, do I just run
bundle
orbundle install
?Seth Reece
32,867 PointsSeth Reece
32,867 PointsBundle should work. If not you might need to edit you Gemfile.lock to remove rspec from it and rebundle. (Or delete Gemfile.lock and run bundle. As an example of putting configuration files in rails helper...
Hope that makes sense.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsI ran
bundle
after making the changes to spec_helper which was successful. Here's my spec_helper.rb file (which looks a lot like the rails_helper.rb that you showed me)Seth Reece
32,867 PointsSeth Reece
32,867 PointsYea, it appears that you probably started with rspec 2 and then later changed to rspec 3 in your gem file. I would stick with rspec 2 for the course, but would encourage you to create an app afterwards using rspec 3.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsI give up. It's not working. I changed to rspec 3 because at the beginning of the new course, they suggested using the newer version for Installing a Ruby Development Environment which messed up my whole odot project. It's just super confusing and annoying.
The videos themselves use rspec 2, shouldn't they make a separate set of videos for rspec 3 that uses this newer version from beginning to the end? Instead of including rspec 3 midway and suggesting including this newer version which ended up not matching the rspec 2 videos.
Seth Reece
32,867 PointsSeth Reece
32,867 PointsIt's a bit confusing at first. At the rate of speed that Ruby on Rails changes, it's not a bad idea to learn older stuff. Take a look at the version history. You might find yourself having to work on an older project. It's important to lock in gem versions so that anyone, at anytime can run an app. Then look at any changes in gems if they want to upgrade. I would suggest going with rspec 2 since that's what Jason used, then look at his workshop on upgrading an app.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsThe problem is, I can't even go back to rspec 2 anymore as my whole odot project now is messed up because they included rspec 3 in User Authentication part of the project as if to suggest we should upgrade midway in the project instead of separating the 2 versions since they are not compatible or show steps to make them work together if possible. I can't continue with it anymore. I have wasted time and money trying to figure it out on my own and make it work to no avail.
It took me forever to get to this point in the odot project, I'm not about to start all over again.
But thanks anyway, for your effort.
Seth Reece
32,867 PointsSeth Reece
32,867 PointsMake a backup copy of spec_helper.rb.
If you have a rails_helper.rb file, delete it.
Change your gem to:
gem 'rspec-rails', '~> 2.0'
Then in your console type:
bundle install
then in your console type:
rails generate rspec:install
You will get a conflict message for .rspec. Choose Y. You will get a conflict message for spec_helper.rb. Choose Y
In the newly created spec_helper.rb add the line:
require 'capybara/rspec'
Right below:
require 'rspec/rails'
I believe "./spec/views/users/show.html.erb_spec.rb" is the only file you have with "require 'rails_helper'. Change that to spec_helper.
You should be good to go. If there are any other configurations that you need for spec_helper.rb, you made a backup to compare to.
kabir k
Courses Plus Student 18,036 Pointskabir k
Courses Plus Student 18,036 PointsThanks, Seth. I really appreciate your taking the time to provide the steps to solve this problem. I will have to find time to come back and do it again to see if it works.