Ruby Guard получает: Обычно разрешено только одно использование каждого адреса сокета. Ошибка::EADDRINUSE

Я работаю над главой 3.6 Учебника по Rails, поэтому я пытаюсь реализовать Rspec, Guard и Spork. На данный момент кажется, что все работает, но меня мучает ошибка EADDRINUSE при запуске Guard. Моя среда — Windows 8 x64, BiNami Rubystack 1.9.3-6, Ruby 1.9.3p392, Rails 3.2.13 и RubyMine 5.4.2. Такая же ошибка возникает либо в RubyMine, либо в CLI.

Я использовал netstat для проверки того, что порты не используются до запуска Guard и после завершения работы Guard. Таким образом, гвардия кажется единственным фактором. Я искал похожие проблемы и убедился, что не нашел ни одной проблемы. Я попытался минимизировать свою среду, чтобы изолировать проблему, но безуспешно. Например, я попытался устранить лишние драгоценные камни, а также попытался сделать те, которые были указаны, универсальными без указания версии. Ничто из того, что я сделал, не имело никакого значения.

Мой гемфайл:

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'

Мой 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

Запись об ошибке:

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)> 

Мой 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

person Richard_G    schedule 03.06.2013    source источник
comment
Вы уверены, что он читает Guardfile? Он запускает Spork дважды, а также, похоже, запускает другие вещи. Если это не весь файл Guardfile, укажите ссылку на полный файл.   -  person Jim Stewart    schedule 04.06.2013
comment
Когда я вношу изменения в этот Guardfile, они отражаются в выводе, поэтому я уверен, что это тот самый файл. Файл Guardfile немного больше, но я закомментировал все ниже, что указано с =begin. Я думаю, что два Spork — это Rspec и Cucumber, верно? Но в настоящее время я не использую Cucumber. Я попытался полностью отключить его, удалив драгоценные камни и закомментировав команды, но это только доставило мне больше проблем.   -  person Richard_G    schedule 04.06.2013


Ответы (1)


Эта проблема была решена путем переустановки BitNami Rubystack.

person Richard_G    schedule 25.07.2013