0
我正在通過Rails教程第3.6章的工作,所以我試圖實現Rspec,Guard和Spork。此時,一切似乎都正常,但Guard啓動時EADDRINUSE錯誤困擾着我。我的環境是Windows 8 x64,BiNami Rubystack 1.9.3-6,Ruby 1.9.3p392,Rails 3.2.13和RubyMine 5.4.2。 RubyMine或CLI中都會發生同樣的錯誤。Ruby Guard收到:通常只允許使用每個套接字地址。 Errno :: EADDRINUSE
我使用netstat來驗證在啓動Guard之前和Guard終止之後端口未被使用。所以,衛隊似乎是唯一的因素。我搜索了類似的問題,並確保我找不到與我遇到的問題相匹配的問題。我試圖儘量減少我的環境,以隔離問題而沒有成功。例如,我試圖消除多餘的寶石,並試圖使那些沒有版本規範的通用指定。我所做的一切都沒有改變。
我的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'
我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
你確定它正在讀Guardfile嗎?它開始Spork兩次,也似乎開始其他事情。如果這不是整個Guardfile,請提供完整文件的鏈接。 –
當我對Guardfile進行更改時,它們會反映在輸出中,因此我確信它就是那個。 Guardfile比較大,但我在下面提供了一個= begin的內容。我認爲這兩個Sporks是Rspec和黃瓜,對嗎?但是,我現在不使用黃瓜。我試圖通過刪除寶石和註釋命令完全禁用它,但這只是給我帶來了更多問題。 –