I'm building a rails app and using Spork/Guard/Rspec for testing.
I'm on a mac (10.6.8) -- here are the gems I'm using:
gem "rspec-rails", "~> 2.12.1"
gem "guard-rspec", "~> 2.3.3"
gem "guard-spork", "~> 1.4.1"
gem "spork", "~> 0.9.2"
gem 'rb-fsevent', '~> 0.9.1', :require => false
gem "growl", "~> 1.0.3"
gem 'capybara', '1.1.2'
When I edit my routes file it should restart the spork server here's the line in my Guardfile:
guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' }, :foreman => true do
watch('config/routes.rb')
end
But recently I just started getting the following error when I add a new route:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Address already in use - bind(2) (Errno::EADDRINUSE)
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:861:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:759:in `block in open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `each'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:757:in `open_server'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1342:in `initialize'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `new'
/Users/cyrus/.rvm/rubies/ruby-1.9.3-p125/lib/ruby/1.9.1/drb/drb.rb:1624:in `start_service'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/server.rb:29:in `listen'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/server.rb:20:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/runner.rb:75:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/lib/spork/runner.rb:10:in `run'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/gems/spork-0.9.2/bin/spork:10:in `<top (required)>'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/bin/spork:23:in `load'
/Users/cyrus/.rvm/gems/ruby-1.9.3-p125#h/bin/spork:23:in `<main>'
Usually when spork boots up I get the following:
Loading Spork.prefork block...
Rack::File headers parameter replaces cache_control after Rack 1.5.
Spork is ready and listening on 8989!
How do I avoid this error?
I came here suffering the same problem as the OP.
After going down the rabbit hole of the 'error is a bug' post, and examining the line of code where the failure occurred, I rebooted out of frustration. I realized after doing this that the lock on the port likely came from the fact that I had logged out of the previous desktop session, and that the Spork DRb server hangs RubyMine on closing, so maybe that is what leaves the port open.
Sure enough, I could now start the Spork server.
I add this so other people facing this problem can consider if it matches their situation.
By removing the :foreman => true in the Guardfile I was able to get rid of this problem. Right now I'm not making meaningful use of the values in my .env file in my tests so that should be fine, but I'm submitting an issue on Github.
Looks like this error is a bug: https://github.com/rails/rails/pull/8812
Related
I am doing simple hello world project with rails but it seems it it throwing bundler error to me. I want to see how to remove the bundler errors that comes after i type
rails new helloproject
the errors in the console are:
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:271:in `<class:Path>': uninitialized constant Bundler::GemInstaller (NameError)
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:270:in `<module:Source>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:10:in `<module:Bundler>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/source.rb:9:in `<top (required)>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:21:in `initialize'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `new'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/dsl.rb:6:in `evaluate'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/definition.rb:18:in `build'
/usr/lib/ruby/vendor_ruby/bundler.rb:136:in `definition'
/usr/lib/ruby/vendor_ruby/bundler/cli.rb:222:in `install'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/task.rb:22:in `run'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/invocation.rb:118:in `invoke_task'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor.rb:246:in `dispatch'
/usr/lib/ruby/vendor_ruby/bundler/vendor/thor/base.rb:389:in `start'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `block in <main>'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors'
/var/lib/gems/1.9.1/gems/bundler-1.2.3/bin/bundle:14:in `<main>'
There was an error in your Gemfile, and Bundler cannot continue.
I wonder how can i get past this error and bundle the application properly?
I do manage to run the server and run the hello world app but every new project seems to throw this bundler error.
I have checked similar questions but this one seems to be unique type of the error.
How to get rid of these bundler install errors?
Check the following steps,
gem install bundler
and after adding:
gem 'bundler'
in line 2 in config/boot.rb (just after require 'rubygems')
let me know if not solved.
I have a problem with rails console, here is what I am getting when I try to start rails console:
backo#speedy:~/ucimrails/simple_app$ rails c --sandbox
/home/backo/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:in require': no such file to load -- test/unit/ui/console/testrunner (LoadError)
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:inblock in require'
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in load_dependency'
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:251:inrequire'
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/redgreen-1.2.2/lib/redgreen.rb:2:in <top (required)>'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:inrequire'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:68:in block (2 levels) in require'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:ineach'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:66:in block in require'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:ineach'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler/runtime.rb:55:in require'
from /home/backo/.rvm/gems/ruby-1.9.2-p320#global/gems/bundler-1.1.4/lib/bundler.rb:119:inrequire'
from /home/backo/ucimrails/simple_app/config/application.rb:13:in <top (required)>'
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.2/lib/rails/commands.rb:39:inrequire'
from /home/backo/.rvm/gems/ruby-1.9.2-p320/gems/railties-3.2.2/lib/rails/commands.rb:39:in <top (required)>'
from script/rails:6:inrequire'
from script/rails:6:in `'
I located the problem is caused by redgreen gem. When I exclude it from Gemfile, console works again. But, can someone help me to make it working with redgreen gem? Interesting is that this is only happening on my netbok, when I work on my desktop computer all is fine with rails console.
Specifying in my Gemfile:
gem 'test-unit', '1.2.3'
...seems to work for me with 1.9.3 and Rails 3.2.8. It would, however, be nice to use this with a more recent version of test-unit (looks like 2.5.2 is the latest right now)...
The redgreen gem doesn't work with 1.9.2; for redgreen test output you might try
require 'test/unit'
require 'test/unit/ui/console/testrunner'
class Test::Unit::UI::Console::TestRunner
def guess_color_availability; true; end
end
in your test helper or so.
I'm trying to follow this tutorial, and when I try to use the RSpec generator
$ rails generate rspec:install
I get the following error:
/usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6:in `require': no such file to load -- sqlite3/sqlite3_native (LoadError)
from /usr/lib/ruby/gems/1.8/gems/sqlite3-1.3.5/lib/sqlite3.rb:6
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:68:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:66:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `each'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler/runtime.rb:55:in `require'
from /usr/lib/ruby/gems/1.8/gems/bundler-1.1.3/lib/bundler.rb:119:in `require'
from /home/rcooke/sample_app/config/application.rb:13
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24:in `require'
from /usr/lib/ruby/gems/1.8/gems/railties-3.2.2/lib/rails/commands.rb:24
from script/rails:6:in `require'
from script/rails:6
Following the other discussions on this same problem, I have changed my Gemfile to contain the following:
group :development, :test do
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'sqlite3', '1.3.5'
gem 'rspec-rails'
gem 'rspec'
end
I added both rspec and rspec-rails to the Gemfile after noticing they are both installed:
Using rspec-core (2.9.0)
Using rspec-expectations (2.9.0)
Using rspec-mocks (2.9.0)
Using rspec (2.9.0)
Using rspec-rails (2.9.0)
I've even carried out:
$ gem install rspec
Maybe i'm not using the correct procedure to update. Once I've saved the Gemfile on my computer i'm using bundle update and bundle install. Trying rails generate rspec:install still fails.
Update: when I try to run the resource i get the following error:
$ rake spec
rake aborted!
no such file to load -- sqlite3/sqlite3_native
Update: I've obviously screwed something up. Now if I attempt to start a new application I get the following error.
$ rails new sample_app2 --skip-test-unit
/usr/lib/ruby/site_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [actionmailer-3.2.2, actionpack-3.2.2, activemodel-3.2.2, activerecord-3.2.2, activeresource-3.2.2, activesupport-3.2.2, addressable-2.2.7, arel-3.0.2, builder-3.0.0, bundler-1.1.3, bundler-1.1.2, coffee-rails-3.2.2, coffee-script-2.2.0, coffee-script-source-1.2.0, diff-lcs-1.1.3, erubis-2.7.0, execjs-1.3.0, heroku-2.22.0, heroku-2.21.3, hike-1.2.1, i18n-0.6.0, journey-1.0.3, jquery-rails-2.0.1, json_pure-1.6.6, launchy-2.1.0, mail-2.4.4, mime-types-1.18, multi_json-1.2.0, multi_json-1.1.0, netrc-0.7.1, polyglot-0.3.3, rack-1.4.1, rack-cache-1.2, rack-ssl-1.3.2, rack-test-0.6.1, rails-3.2.2, railties-3.2.2, rake-0.9.2.2, rdoc-3.12, rest-client-1.6.7, rspec-2.9.0, rspec-core-2.9.0, rspec-expectations-2.9.0, rspec-mocks-2.9.0, rspec-rails-2.9.0, rubyzip-0.9.6.1, sass-3.1.15, sass-rails-3.2.5, sprockets-2.3.1, sprockets-2.1.2, sqlite3-1.3.5, sqlite3-ruby-1.3.3, thor-0.14.6, tilt-1.3.3, treetop-1.4.10, tzinfo-0.3.32, uglifier-1.2.3] (Gem::LoadError)
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:772:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:775:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `each'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:761:in `activate_dependencies'
from /usr/lib/ruby/site_ruby/1.8/rubygems/specification.rb:745:in `activate'
from /usr/lib/ruby/site_ruby/1.8/rubygems.rb:1211:in `gem'
from /usr/bin/rails:18
Do you have the SQlite3 library installed on your system? When you look in /usr/lib/ for libsqlite3.so (assuming you're on Linux) do you see it? if not then could you try installing it (via apt-get/portage/your package manager) and see if that helps.
I'm getting a 'no such file' error when I try to require some gems in a rails console. Strangely, I don't get this error when requiring them in irb.
Thanks in advance.
$ irb
irb(main):001:0> $LOAD_PATH
=> ["/usr/local/lib/site_ruby/1.9.1", "/usr/local/lib/site_ruby/1.9.1/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.9.1", "/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.9.1", "/usr/lib/ruby/1.9.1/x86_64-linux"]
irb(main):002:0> require 'rubygems'
=> true
irb(main):003:0> require 'image_science'
=> true
irb(main):004:0> require 'mini_magick'
=> true
irb(main):005:0>
$ rails console
Loading development environment (Rails 3.0.5)
irb(main):001:0> require 'rubygems'
=> nil
irb(main):002:0> require 'image_science'
LoadError: no such file to load -- image_science
from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
...
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):003:0> require 'mini_magick'
LoadError: no such file to load -- mini_magick
from /var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib/active_support/dependencies.rb:239:in `require'
...
from script/rails:6:in `require'
from script/rails:6:in `<main>'
irb(main):004:0> $LOAD_PATH
=> ["/var/lib/gems/1.9.1/gems/haml-3.0.25/vendor/fssm/lib", "/home/username/appname/lib", "/home/username/appname/vendor", "/home/username/appname/app/models", "/home/username/appname/app/mailers", "/home/username/appname/app/helpers", "/home/username/appname/app/controllers", "/var/lib/gems/1.9.1/gems/rails-3.0.5/lib", "/var/lib/gems/1.9.1/gems/railties-3.0.5/lib", "/var/lib/gems/1.9.1/gems/thor-0.14.6/lib", "/var/lib/gems/1.9.1/gems/pg-0.10.1/lib", "/var/lib/gems/1.9.1/gems/pg-0.10.1/ext", "/var/lib/gems/1.9.1/gems/oauth2-0.1.1/lib", "/var/lib/gems/1.9.1/gems/multi_json-0.0.5/lib", "/var/lib/gems/1.9.1/gems/haml-3.0.25/lib", "/var/lib/gems/1.9.1/gems/faraday-0.5.7/lib", "/var/lib/gems/1.9.1/gems/multipart-post-1.1.0/lib", "/var/lib/gems/1.9.1/gems/addressable-2.2.4/lib", "/var/lib/gems/1.9.1/gems/activeresource-3.0.5/lib", "/var/lib/gems/1.9.1/gems/activerecord-3.0.5/lib", "/var/lib/gems/1.9.1/gems/arel-2.0.9/lib", "/var/lib/gems/1.9.1/gems/actionmailer-3.0.5/lib", "/var/lib/gems/1.9.1/gems/mail-2.2.15/lib", "/var/lib/gems/1.9.1/gems/treetop-1.4.9/lib", "/var/lib/gems/1.9.1/gems/polyglot-0.3.1/lib", "/var/lib/gems/1.9.1/gems/mime-types-1.16/lib", "/var/lib/gems/1.9.1/gems/actionpack-3.0.5/lib", "/var/lib/gems/1.9.1/gems/tzinfo-0.3.24/lib", "/var/lib/gems/1.9.1/gems/rack-test-0.5.7/lib", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib", "/var/lib/gems/1.9.1/gems/rack-1.2.1/lib", "/var/lib/gems/1.9.1/gems/erubis-2.6.6/lib", "/var/lib/gems/1.9.1/gems/activemodel-3.0.5/lib", "/var/lib/gems/1.9.1/gems/i18n-0.5.0/lib", "/var/lib/gems/1.9.1/gems/builder-2.1.2/lib", "/var/lib/gems/1.9.1/gems/activesupport-3.0.5/lib", "/var/lib/gems/1.9.1/gems/abstract-1.0.0/lib", "/var/lib/gems/1.9.1/gems/rake-0.8.7/lib", "/var/lib/gems/1.9.1/gems/bundler-1.0.10/lib", "/usr/local/lib/site_ruby/1.9.1", "/usr/local/lib/site_ruby/1.9.1/x86_64-linux", "/usr/local/lib/site_ruby", "/usr/lib/ruby/vendor_ruby/1.9.1", "/usr/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/usr/lib/ruby/vendor_ruby", "/usr/lib/ruby/1.9.1", "/usr/lib/ruby/1.9.1/x86_64-linux", "/var/lib/gems/1.9.1/gems/actionpack-3.0.5/lib/action_controller/vendor/html-scanner", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/vendor/multimap", "/var/lib/gems/1.9.1/gems/rack-mount-0.6.13/lib/rack/mount/vendor/regin"]
Gemfile:
source 'http://rubygems.org'
gem 'rails', '3.0.5'
gem 'pg'
gem 'oauth2'
gem 'haml'
You cannot require gems in Rails that are not in your Gemfile. You have to either include them in your Gemfile, or specify the full path to the gem when requiring, e.g. require "/full/path/to/gem".
This is because of the way Bundler works and overrides your existing load path. If you run $LOAD_PATH in the Rails console you'll see that it differs significantly from the one in IRB.
gem 'rails', '3.0.0'
gem 'devise'
gem 'bson_ext', '>= 1.0.7'
gem 'bson', '>= 1.0.7'
gem 'mongo_mapper', :branch => 'rails3', :git => 'http://github.com/jnunemaker/mongomapper.git'
gem 'devise-mongo_mapper', :git => 'git://github.com/collectiveidea/devise-mongo_mapper'
With the above setup I get the following errors on requests:
Started GET "/users/sign_out" for 127.0.0.1 at 2010-09-27 13:16:30 +0300
Processing by Devise::SessionsController#destroy as HTML
Redirected to http://localhost:3000/
Completed 302 Found in 19ms
[2010-09-27 13:16:31] ERROR Errno::ECONNRESET: Connection reset by peer
/usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?'
/usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run'
/usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
Started GET "/users/edit" for 127.0.0.1 at 2010-09-27 13:16:35 +0300
Processing by Devise::RegistrationsController#edit as HTML
Completed in 16ms
[2010-09-27 13:16:35] ERROR Errno::ECONNRESET: Connection reset by peer
/usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `eof?'
/usr/local/ruby/lib/ruby/1.9.1/webrick/httpserver.rb:56:in `run'
/usr/local/ruby/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'
The user model:
class User
include MongoMapper::Document
plugin MongoMapper::Devise
devise :registerable, :database_authenticatable, :recoverable
end
Ideas?
WebRick has been replaced with Thin.
Doing the following worked for me:
Gemfile:
gem 'thin'
Now do bundle install
My quick guess is this looks like you have a problem with your sessions and protect_from_forgery is kicking in.
I had a similar problem and smashed my head against the wall for a few days, it turned out to be I was assigning an entire object to a session object instead of just the id. A quick note, non-GET requests are the ones that trigger the protect_from_forgery.
Adding this to my development.rb file fixed the issue.
config.assets.raise_runtime_errors = true
config.web_console.whitelisted_ips = replace_this_with_the_public_ip