-
Notifications
You must be signed in to change notification settings - Fork 202
Troubleshooting
Common issues with Spork, and how to overcome.
See http://pragmatig.wordpress.com/2009/09/27/speeding-up-slow-spork-startup-for-rails-2-3/
If you’re using ActiveRecord and Rails, Spork will automatically reconnect to the database. However, if you’re not using ActiveRecord, or if you’re doing some tricky stuff with connections, you’ll have to make sure your connections get re-established on each run. In your spec/spec_helper.rb
file:
Spork.each_run do
# Do your connection re-establishing here
end
If you see this error message:
Make sure the --require option is specified *before* --format
On one of our projects, many of us using TextMate with spork, only one developer got this error message while the rest of us ran just fine. I don’t know exactly why it happened, but requiring the textmate formatter in the prefork block made it go away, like this:
Spork.prefork do
gem "rspec", "= 1.2.6"
require 'spec'
# ...
require 'spec/runner/formatter/text_mate_formatter'
# ...
end
This is kind of an issue with RSpec. See this ticket for more info:
Basically, just remove the unless defined?(RAILS_ROOT)
from your spec/spec_helper.rb
, and this should go away.
Your file is getting preloaded in your prefork block. Anything in the prefork block is cached during the life of the spork server (this is what makes it run faster than otherwise). Run spork -d
to help you find out which files are being preloaded, and why.
Some eager plugins (including latest version of Thinking Sphinx) load the contents of your app folder. You can see which by inspecting the output of spork -d > spork.log
. See Kickstart Rspec with Spork for more details.
See Spork.trap_method Jujitsu for various solutions.
You are using Ruby 1.9.2, and the bundled rake is not set up quite right.
http://betterlogic.com/roger/2010/11/ruby-1-9-2-rake-woe/
locate your rake.gemspec file and delete it.
See this ticket and this StackOver flow post
See the issue on the formtastic project for details
Workaround found by rmm5t is to load any custom input classes explicitly in the prefork block
Spork.prefork do
# ...
# Load all files under app/inputs. Neccesary to get Formtastic's custom inputs
# to work in a Spork environment while config.cache_classes is set to true
Dir["app/inputs/*_input.rb"].each { |f| require File.basename(f) }
end