Ruby Guard receives: Only one usage of each socket address is normally permitted. Errno::EADDRINUSE

StackOverflow https://stackoverflow.com/questions/16906414

Question

I am working through the Rails Tutorial chapter 3.6 so I am trying to implement Rspec, Guard and Spork. At this point, everything seems to be working but I am plagued by the EADDRINUSE error when Guard starts up. My environment is Windows 8 x64, BiNami Rubystack 1.9.3-6, Ruby 1.9.3p392, Rails 3.2.13 and RubyMine 5.4.2. The same error occurs either in RubyMine or in CLI.

I used netstat to verify the ports are not in use prior to starting Guard and after Guard is terminated. So, Guard seems to be the only factor. I have searched on similar problems and made sure that I didn't match the issue in any I found. I tried to minimize my environment to isolate the problem without success. For example, I tried to eliminate excess gems and also tried to make those that were specified generic without version specifications. Nothing I have done has made any difference.

My Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.13'

group :development, :test do
    gem 'rspec-rails', '2.13.2'
  gem 'database_cleaner'
  gem 'guard'
  gem 'win32console'
  gem 'growl'
  gem 'ruby_gntp'
  gem 'rb-notifu'
  gem 'guard-rspec'
  gem 'wdm'
  gem 'guard-spork', '1.2.0'
  gem 'childprocess', '0.3.6'
  gem 'spork', '1.0.0rc3'
  gem 'spork-rails'
  gem 'cucumber'
  gem 'cucumber-rails', :require => false
end

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

My Guardfile:

require 'active_support/core_ext'

guard 'spork', :rspec_env => { 'RAILS_ENV' => 'test' } do
  watch('config/application.rb')
  watch('config/environment.rb')
  watch(%r{^config/environments/.+\.rb$})
  watch(%r{^config/initializers/.+\.rb$})
  watch('Gemfile')
  watch('Gemfile.lock')
  watch('spec/spec_helper.rb')
  watch('test/test_helper.rb')
  watch('spec/support/')
end

The error record:

D:\BitNami\rubystack-1.9.3-6\ruby\bin\ruby.exe -e $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift) D:/BitNami/rubystack-1.9.3-6/ruby/bin/bundle exec guard
17:03:39 - INFO - Guard uses GNTP to send notifications.
17:03:39 - INFO - Guard uses TerminalTitle to send notifications.

17:03:40 - INFO - Starting Spork for RSpec, Cucumber
Using RSpec, Rails
Using Cucumber, Rails
  -- Rinda Ring Server listening for connections...

D:/BitNami/rubystack-1.9.3-6/ruby/lib/ruby/1.9.1/rinda/ring.rb:35:in `bind': Only one usage of each socket address (protocol/network address/port) is normally permitted. - bind(2) (Errno::EADDRINUSE)
    from D:/BitNami/rubystack-1.9.3-6/ruby/lib/ruby/1.9.1/rinda/ring.rb:35:in `initialize'
    from ring_server.rb:7:in `new'
    from ring_server.rb:7:in `<main>'
  -- Starting to fill pool...
     Wait until at least one slave is provided before running tests...
  ** CTRL+BREAK to stop Spork and kill all ruby slave processes **
  -- Starting to fill pool...
     Wait until at least one slave is provided before running tests...
  ** CTRL+BREAK to stop Spork and kill all ruby slave processes **
Spork is ready and listening on 8989!
Spork is ready and listening on 8990!
   -- build slave 1...
   -- build slave 2...
Preloading Rails environment
   -- build slave 1...
   -- build slave 2...
Preloading Rails environment
Preloading Rails environment
Preloading Rails environment
Loading Spork.prefork block...
Loading Spork.prefork block...
Loading Spork.prefork block...
Loading Spork.prefork block...
  --> DRb magazine_slave_service: 1 provided...
  --> DRb magazine_slave_service: 2 provided...
  --> DRb magazine_slave_service: 1 provided...
  --> DRb magazine_slave_service: 2 provided...

17:03:59 - INFO - Spork server for RSpec, Cucumber successfully started
17:03:59 - INFO - Guard is now watching at 'D:/BitNami/rubystack-1.9.3-6/projects/sample_app'
]2;[Spork] RSpec, Cucumber successfully started
ain)> 

ain)> 

My spec_helper.rb

require 'rubygems'
require 'spork'

#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'

Spork.prefork do
  # Loading more in this block will cause your tests to run faster. However,
  # if you change any configuration or code from libraries loaded here, you'll
  # need to restart spork for it take effect.

  # This file is copied to spec/ when you run 'rails generate rspec:install'
  ENV["RAILS_ENV"] ||= 'test'
  require File.expand_path("../../config/environment", __FILE__)
  require 'rspec/rails'
  require 'rspec/autorun'

  #20130530 RGR Installing Spork. The following code existed and was moved to Spork.prefork
  # Requires supporting ruby files with custom matchers and macros, etc,
  # in spec/support/ and its subdirectories.
  Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

  RSpec.configure do |config|
    # ## Mock Framework
    #
    # If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
    #
    # config.mock_with :mocha
    # config.mock_with :flexmock
    # config.mock_with :rr
    config.mock_with :rspec

    # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
    config.fixture_path = "#{::Rails.root}/spec/fixtures"

    # If you're not using ActiveRecord, or you'd prefer not to run each of your
    # examples within a transaction, remove the following line or assign false
    # instead of true.
    config.use_transactional_fixtures = true

    # If true, the base class of anonymous controllers will be inferred
    # automatically. This will be the default behavior in future versions of
    # rspec-rails.
    config.infer_base_class_for_anonymous_controllers = false
end

Spork.each_run do
  # This code will be run each time you run your specs.

  end
end
Was it helpful?

Solution

This problem was resolved with a reinstall of BitNami Rubystack.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top