Spork cannot load such file?
Asked Answered
R

6

5

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!
Risa answered 12/6, 2012 at 0:40 Comment(0)
C
10

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.

Chemash answered 13/6, 2012 at 19:39 Comment(5)
try also to re-run a bundle installChemash
To fix my system, I repeatedly updated file permissions like @Fabrice said, on each file that failed to load. In all I updated permissions on 8 files in the gem directory.Workhorse
I had to do a chmod -R a+rExcelsior
Thank you for this! I had to do it to all the files in both spork-1.0.0rc3 and spork-rails-3.2.0Nuno
Seems ok on mine.... $ ls -l vendor/bundle/ruby/2.1.0/gems/spork-1.0.0rc4/bin/ ==== -rwxr-xr-x 1 nthompson staff 460 9 Sep 15:27 sporkUela
R
1

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.

Rainbolt answered 12/6, 2012 at 13:47 Comment(0)
M
1

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.

Mishamishaan answered 14/6, 2012 at 0:6 Comment(0)
N
1

I use Rails 3.2.12 and ruby-1.9.3-p392. In my case, adding require 'spork' into my Gemfile and running bundle install did the trick.

Nazarite answered 26/4, 2013 at 11:35 Comment(0)
E
0

I actually just ran into the same problem. In my environments/test.rb file, I had set config.cache_classes to true.

In actuality, config.cache_classes needs to be set to false for Spork to work properly.

Embed answered 24/10, 2012 at 22:37 Comment(0)
H
0

I Had the same problem. I had a

require 'spec_helper'

line within the spec_helper.rb file itself... lets say requiring spec_helper.rb file in a recursive manner. Just eliminate that line and everything is running ok now.

Hypersonic answered 5/10, 2014 at 18:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.