使用 Spork 和 Guard 时启动错误
Posted
技术标签:
【中文标题】使用 Spork 和 Guard 时启动错误【英文标题】:Error on start when using Spork and Guard 【发布时间】:2013-01-13 11:10:43 【问题描述】:这就是问题所在。当添加Guard gem
时,我打电话给Guard
时一切都很好。
当我添加 Spork
时,我收到以下错误,它不会影响测试我的测试,但每次我尝试重新启动 Guard 时都会出现此错误。
19:01:28 - INFO - Guard uses TerminalTitle to send notifications.
19:01:28 - INFO - Starting Spork for RSpec
19:01:28 - ERROR - Guard::Spork failed to achieve its <start>, exception was:
[#5232DAD6505A] ChildProcess::LaunchError: 没有这样的文件或目录 - bundle exec spork -p 8989 [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/childprocess-0.3.7/lib/childprocess/unix/fork_exec_process.rb:54:in
launch_process' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/childprocess-0.3.7/lib/childprocess/abstract_process.rb:68:in
start' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-spork-1.2.0/lib/guard/spork/spork_instance.rb:38:instart' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-spork-1.2.0/lib/guard/spork/runner.rb:33:in
each' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-spork-1.2.0/lib/guard/spork/runner.rb:33:inlaunch_sporks' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-spork-1.2.0/lib/guard/spork.rb:21:in
start' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:99:inblock in run_supervised_task' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:97:in
catch' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:97:inrun_supervised_task' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:54:in
block(2 级)在跑步' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:175:inblock (3 levels) in scoped_guards' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:174:in
each' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:174:inblock (2 levels) in scoped_guards' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:173:in
catch' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:173:inblock in scoped_guards' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:172:in
each' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:172:inscoped_guards' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:53:in
block in run' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/lumberjack-1.0.2/lib/lumberjack.rb:27:inunit_of_work' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/runner.rb:52:in
run' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard.rb:187:inblock in start' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard.rb:363:in
block in within_preserved_state' [#5232DAD6505A] :10:insynchronize' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard.rb:360:in
within_preserved_state' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard.rb:185:instart' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/lib/guard/cli.rb:110:in
start' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/thor-0.17.0/lib/thor/task.rb:27:inrun' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/thor-0.17.0/lib/thor/invocation.rb:120:in
invoke_task' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/thor-0.17.0/lib/thor.rb:344:indispatch' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/thor-0.17.0/lib/thor/base.rb:434:in
start' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/gems/guard-1.6.2/bin/guard:6:in<top (required)>' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/bin/guard:19:in
load' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/bin/guard:19:in<main>' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in
eval' [#5232DAD6505A] /Users/periclestheodorou/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `' 19:01:28 - 信息 - Guard::Spork 刚刚被解雇 19:01:28 - 信息 - Guard::RSpec 正在运行,使用 RSpec 2! 19:01:28 - 信息 - 运行所有规格 没有 DRb 服务器正在运行。而是在本地进程中运行... 未找到示例。
在 0.0001 秒内完成 0 个例子,0 个失败
这是 Gemfile
source 'https://rubygems.org'
gem 'rails', '3.2.11'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.11.0'
gem 'guard-rspec', '1.2.1'
gem 'guard-spork', '1.2.0'
gem 'spork', '0.9.2'
end
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails'
group :test do
gem 'capybara', '1.1.2'
gem 'rb-fsevent', '0.9.1', :require => false
end
group :production do
gem 'pg', '0.12.2'
end
spec_helper
require 'rubygems'
require 'spork'
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'
# 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
end
Spork.each_run do
# This code will be run each time you run your specs.
end
【问题讨论】:
您没有提供很多信息。但是,看看这个rails cast。 railscasts.com/episodes/285-spork,一步一步来,用 spork 运行 Guard 应该没问题。 您还需要什么其他信息?我看了一下 RailsCast;我或多或少地基于它添加了 spork 和 guard 你的规范助手是什么样的? 在问题中添加了 spec_helper 添加 spork 后,您运行了 bundle install 吗?请注意也发布您的保护文件 【参考方案1】:这是一个known issue in guard-spork
,您可以通过添加以下内容来使用ChildProcess
的早期版本:
gem 'childprocess', '0.3.6'
到您的 Gemfile
或尝试使用有 fixed the issue 的 guard-spork master 分支,方法是将以下内容添加到您的 Gemfile
:
gem 'guard-spork', :github => 'guard/guard-spork'
【讨论】:
太棒了,非常感谢。我最终使用了 gem 'guard-spork', :github => 'guard/guard-spork' 也帮助了我,在 Mac 上运行最新的 Mountain Lion。谢谢。 这已在guard-spock 1.4.2 上解决,因此您可以更改为gem 'guard-spork', '1.4.2'。 我更新了我的 gemfile 以使用gem 'guard-spork', '1.4.2'
并解决了这个问题。谢谢@leolobato!
我从我的 Gemfile 中的 guard-spork 中删除了版本 (1.2.0),运行了捆绑更新,将它升级到版本 1.5.0 并为我解决了同样的问题。【参考方案2】:
将 Gemfile 更新为“guard-spork”、“1.4.2”并为我修复了它。
【讨论】:
【参考方案3】:跑步
bundle exec guard
而不是
guard
帮我修好了
【讨论】:
以上是关于使用 Spork 和 Guard 时启动错误的主要内容,如果未能解决你的问题,请参考以下文章
win10专业版启动虚拟机报错VMware Workstation 与 Device/Credential Guard 不兼容
解決 VMware Workstation 与 Device/Credential Guard 不相容,无法启动虚拟机的问题