Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spork cannot load such file?

I have a spork gem issue. Every time I run the spork command I get this long error:

evan@TheBeast-Computer:~/rails_projects/sample_app$ spork
Using RSpec
Preloading Rails environment
Loading Spork.prefork block...
cannot load such file -- /home/evan/rails_projects/sample_app/spec_helper (LoadError)
/home/evan/rails_projects/sample_app/spec/spec_helper.rb:57:in `require_relative'
/home/evan/rails_projects/sample_app/spec/spec_helper.rb:57:in `block in <top (required)>'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork.rb:24:in `prefork'
/home/evan/rails_projects/sample_app/spec/spec_helper.rb:6:in `<top (required)>'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:245:in `load'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:245:in `block in load'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:236:in `load_dependency'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.5/lib/active_support/dependencies.rb:245:in `load'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/test_framework.rb:138:in `block (2 levels) in preload'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/app_framework/rails.rb:8:in `preload'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/test_framework.rb:134:in `block in preload'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork.rb:62:in `exec_prefork'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/test_framework.rb:120:in `preload'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/run_strategy/forking.rb:25:in `preload'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/runner.rb:74:in `run'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run'
/home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/bin/spork:10:in `<top (required)>'
/home/evan/.rvm/gems/ruby-1.9.3-p194/bin/spork:23:in `load'
/home/evan/.rvm/gems/ruby-1.9.3-p194/bin/spork:23:in `<main>'

Here is my Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.5'

gem 'sqlite3'

group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

group :development, :test do
  gem 'rspec-rails',    ">= 2.0.1"
end

group :test do
  gem 'rspec-rails', '>= 2.0.1'
  gem 'spork', '>= 0.8.4'
end

I'm at a loss of what to do or how to describe my situation. But the result I'm seeing in the Ruby on Rails 3 Tutorial book shows:

$ spork
Using RSpec
Loading Spork.prefork block...
Spork is ready and listening on 8989!
like image 833
Evan Avatar asked Jun 12 '12 00:06

Evan


3 Answers

Just experienced the same problem after a system update. This was due to a missing read privilege on the file.

A simple chmod +r worked for me :

sudo chmod +r /home/evan/.rvm/gems/ruby-1.9.3-p194/gems/spork-0.9.2/bin/spork

EDIT

I had once again the problem when updating to Rails 3.2.9 & Ruby 1.9.3-p327. Unfortunately this did not come from acces right issue this time but from a gem that evolved between the two updates (shoulda, to be totally transparent). So if you get this issue, you should also check which file are missing if you have no access right privilege problem and upgrade correctly the corresponding gems.

like image 63
Fabrice Carrega Avatar answered Dec 28 '22 06:12

Fabrice Carrega


By the look of it, you have 'spec_helper.rb' file in 'spec' folder which spork tries to load and inside this file on line 57 you have a block inside which you have a require_relative "../spec_helper" statement which points to 'spec_helper.rb' file in a root project folder and ruby 'cannot load such file' because it's missing.

like image 26
Art Shayderov Avatar answered Dec 28 '22 06:12

Art Shayderov


Had the same problem but was able to go into the spec_help.rb file and just save it. Once I did that it started working.

like image 23
Jamon Holmgren Avatar answered Dec 28 '22 06:12

Jamon Holmgren