Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No such file or directory @ rb_sysopen 'rspec_guard_result' with zeus #359

Closed
ryankc33 opened this issue Jan 29, 2016 · 24 comments
Closed

Comments

@ryankc33
Copy link

I know this has been a recurring issue and the solutions offered in #326 and #348 has worked previously, but the solutions did not work in my case and the error remains unresolved.

rspec (3.4.0)
guard-rspec (4.6.4)
guard (2.13.0)

I've tried setting a custom_plan.rb with zeus

require 'zeus/rails'

class CustomPlan < Zeus::Rails
    def test(*args)
      ENV['GUARD_RSPEC_RESULTS_FILE'] = File.expand_path('rspec_guard_result')
      super
    end
end
Zeus.plan = CustomPlan.new

and passed the results_file option to guard

rspec_options = {
  results_file: File.expand_path('rspec_guard_result'),
  cmd: "zeus rspec",
  all_after_pass: false,
  failed_mode: :focus,
  notification: false
}

guard 'rspec', rspec_options do
  ....

in addition to changing 'File.expand_path('rspec_guard_result' to 'tmp/rspec_guard_result.txt' according to the readme but the error keeps cropping up.

Modifying the results file path and reloading zeus would work for a short while, and I would actually see the rspec_guard_result file being created and destroyed during the tests, but after a few modifications the error would occur again and guard would crash.

ERROR - Guard::RSpec failed to achieve its <run_on_modifications>, exception was:
> [#] Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/macintosh/rails_projects/mocha/rspec_guard_result
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `readlines'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `initialize'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `new'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `_read_results'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:17:in `initialize'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `new'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `_really_run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:57:in `_run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:41:in `run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:42:in `block in run_on_modifications'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:48:in `_throw_if_failed'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:42:in `run_on_modifications'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:82:in `block in _supervise'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `catch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `_supervise'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:61:in `block (3 levels) in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:56:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:56:in `block (2 levels) in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:119:in `block (2 levels) in _run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `block in _run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `catch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `_run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:54:in `block in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:53:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:53:in `run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:23:in `process'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/commander.rb:43:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli.rb:122:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:32:in `execute'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/bin/_guard-core:11:in `<main>'
23:22:13 - INFO - Guard::RSpec has just been fired
@e2
Copy link
Contributor

e2 commented Jan 29, 2016

Set it to a custom path to make sure, e.g. File.expand_path('tmp/rspec_results')

That way, if it fails, at least we'll know if the environment variable is passed.

@e2
Copy link
Contributor

e2 commented Jan 29, 2016

Are you sure you restarted zeus? Are you sure the environment is set up in the test plan is preserved?

If you create a repo with the problem I can take a look.

@ryankc33
Copy link
Author

@e2 I've taken the following steps and the error is still occuring

  1. I've changed the custom plan as follows to force the environment variable to load in all envs:
require 'zeus/rails'
class CustomPlan < Zeus::Rails
  def boot
    ENV['GUARD_RSPEC_RESULTS_FILE'] = File.expand_path('tmp/rspec_results') # can be anything matching Guard::RSpec :results_file option in the Guardfile
    super
  end
end
Zeus.plan = CustomPlan.new
  1. Ensured the guardfile is loading the right results_file location
rspec_options = {
  results_file: File.expand_path('tmp/rspec_results'),
  cmd: "zeus rspec",
  all_after_pass: false
 }
guard 'rspec', rspec_options do
  ....
  1. restarted zeus and opened zeus console to confirm that the enviroment variable is loaded
$ zeus start
$ zeus c
> ENV["GUARD_RSPEC_RESULTS_FILE"]=>"/Users/macintosh/rails_projects/mocha/tmp/rspec_results"
  1. run bundle exec guard, modified a .spec file a few times to test it out, guard would work for a few modifications before crashing.
Finished in 0.79674 seconds (files took 20 minutes 21 seconds to load)
6 examples, 6 failures

Finished in 0.84189 seconds (files took 20 minutes 15 seconds to load)
6 examples, 5 failures 

20:00:36 - ERROR - Guard::RSpec failed to achieve its <run_on_modifications>, exception was:
>[#] Errno::ENOENT: No such file or directory @ rb_sysopen - /Users/macintosh/rails_projects/mocha/tmp/rspec_results
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `readlines'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `initialize'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `new'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `_read_results'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:17:in `initialize'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `new'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `_really_run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:57:in `_run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:41:in `run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:42:in `block in run_on_modifications'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:48:in `_throw_if_failed'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:42:in `run_on_modifications'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:82:in `block in _supervise'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `catch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `_supervise'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:61:in `block (3 levels) in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:56:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:56:in `block (2 levels) in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:119:in `block (2 levels) in _run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `block in _run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `catch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `_run_group_plugins'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:54:in `block in run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:53:in `each'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:53:in `run_on_changes'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:23:in `process'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/commander.rb:43:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli.rb:122:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:32:in `execute'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#] /Users/macintosh/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/guard-2.13.0/bin/_guard-core:11:in `<main>'
20:00:36 - INFO - Guard::RSpec has just been fired

The odd thing is that I would change the file path in the environment variable and restart zeus, and occasionally guard would work for one or two spec modifications before crashing.

@ryankc33
Copy link
Author

@e2 Here's a vanilla rails repo replicating the issue.

https://github.com/ryankc33/guard-rspec-zeus

@e2
Copy link
Contributor

e2 commented Feb 1, 2016

Seems to work fine for me.

Probably needs some serious debugging.

The results file is read and then deleted. If it doesn't exist, then maybe another session deleted it already? (If e.g. you have multiple guard-rspec instances running). Also, rspec uses it's own results file, so it's best to make sure they're not shared.

The RSpecFormatter class creates the file (after tests have been run) and RSpecProcess class reads them, and then deletes them.

https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec/rspec_process.rb#L48

If you add debugs to track when the file is created and when it's deleted, that might help pinpoint the problem.

@ryankc33
Copy link
Author

ryankc33 commented Feb 1, 2016

@e2 Ok after some hard debugging I've narrowed it down to this line in rspec_process.rb:

  def _really_run
    env = { "GUARD_RSPEC_RESULTS_FILE" => formatter_tmp_file }
    pid = Kernel.spawn(env, command) # use spawn to stub in JRuby
    #######################
    result = ::Process.wait2(pid)
    #######################
    result.last.exitstatus
  rescue Errno::ENOENT => ex
    fail Failure, "Failed: #{command.inspect} (#{ex})"
  end

During runs that ran without issues, this line would trigger rspec_formatter to dump_summary.
During runs that threw the no such file error, rspec_formatter is not triggered, hence the missing results file.

Any pointers as to how to proceed?

@ryankc33 ryankc33 closed this as completed Feb 2, 2016
@ryankc33 ryankc33 reopened this Feb 2, 2016
@ryankc33
Copy link
Author

ryankc33 commented Feb 2, 2016

It seems that the problem lies not with Guard-rspec but with Zeus. Closing this issue for now.

burke/zeus#469

@ryankc33 ryankc33 closed this as completed Feb 2, 2016
@e2
Copy link
Contributor

e2 commented Feb 2, 2016

If there's any way guard-rspec could've helped debug this, let me know.

@suranyami
Copy link
Member

I'm getting this and we make no use of Zeus.

@suranyami
Copy link
Member

The problem seems to be when there are syntax errors in some tests.

I had some tests that had been converted incorrectly from minitest to rspec using the minitest_to_rspec gem. They were creating entries like this:

require "rails_helper"
RSpec.describe CardBalance, type: :model { }

When I ran this just using the rspec CLI, this is what I got:

/Users/djp/.rvm/gems/ruby-2.2.3@cms/gems/activesupport-3.2.22/lib/active_support/dependencies.rb:245:in `load': /Users/djp/development/work/cms-kiosk/spec/unit/admin_user_spec.rb:2: syntax error, unexpected '{', expecting end-of-input (SyntaxError)
RSpec.describe AdminUser, type: :model { }
                                        ^

Removing the offending (and useless) tests solved the problem for me.

@e2
Copy link
Contributor

e2 commented Feb 8, 2016

@suranyami - can you create a small repo to reproduce this so I can kill this bug? I can't seem to reproduce it myself.

@suranyami
Copy link
Member

I've started a repo here:

guard-rspec-problems

Currently, it does NOT fail the way I observed, but I'm copy/pasting configs over from the failing app slowly to see what causes it to break.

I'll keep you tuned.

guard-rspec: 4.6.4
ruby: 2.2.3
Bundler: 1.11.2
Rails: 3.2.22

The Rails version being 3.x was a surprise to me, but then I realised we are half-way through upgrading this app to Rails 4.x. This may be an important factor. Then again, it might not.

@suranyami
Copy link
Member

Guardfile:

guard :bundler do
  require 'guard/bundler'
  require 'guard/bundler/verify'
  helper = Guard::Bundler::Verify.new

  files = ['Gemfile']
  files += Dir['*.gemspec'] if files.any? { |f| helper.uses_gemspec?(f) }

  # Assume files are symlinked from somewhere
  files.each { |file| watch(helper.real_path(file)) }
end

rspec_options = {
  all_after_pass: true,
  all_on_start: true,
  cmd: "bin/rspec -f doc",
  failed_mode: :none,
  results_file: File.expand_path('tmp/rspec_results')
}

guard :rspec, rspec_options do
  require "guard/rspec/dsl"
  dsl = Guard::RSpec::Dsl.new(self)

  # Feel free to open issues for suggestions and improvements

  # RSpec files
  rspec = dsl.rspec
  watch(rspec.spec_helper) { rspec.spec_dir }
  watch(rspec.spec_support) { rspec.spec_dir }
  watch(rspec.spec_files)

  # Ruby files
  ruby = dsl.ruby
  dsl.watch_spec_files_for(ruby.lib_files)

  # Rails files
  rails = dsl.rails(view_extensions: %w(erb haml slim))
  dsl.watch_spec_files_for(rails.app_files)
  dsl.watch_spec_files_for(rails.views)

  watch(rails.controllers) do |m|
    [
      rspec.spec.("routing/#{m[1]}_routing"),
      rspec.spec.("controllers/#{m[1]}_controller"),
      rspec.spec.("acceptance/#{m[1]}")
    ]
  end

  # Rails config changes
  watch(rails.spec_helper)     { rspec.spec_dir }
  watch(rails.routes)          { "#{rspec.spec_dir}/routing" }
  watch(rails.app_controller)  { "#{rspec.spec_dir}/controllers" }

  # Capybara features specs
  watch(rails.view_dirs)     { |m| rspec.spec.("features/#{m[1]}") }
  watch(rails.layouts)       { |m| rspec.spec.("features/#{m[1]}") }

  # Factory Girl
  watch(%r{^spec/factories/(.+)\.rb$}) { rspec.spec_dir }

  # Turnip features and steps
  watch(%r{^spec/acceptance/(.+)\.feature$})
  watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
    Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
  end
end

rails_options = {
  force_run: true,
  start_on_start: true,
  CLI: 'bin/rails server'
}

guard 'rails', rails_options do
  watch('Gemfile.lock')
  watch(%r{^(config|lib)/.*})
end

@e2
Copy link
Contributor

e2 commented Feb 8, 2016

Thanks for putting time to reproduce this - as soon as you do, let me know so I can kill this bug.

I'll make sure this error never pops up again, because it's too time consuming to debug.

@e2
Copy link
Contributor

e2 commented Feb 8, 2016

One thing: if you're using cmd: "bin/rspec -f doc", check that file to see if it's using spring or not. Could be related.

Even if you are getting an error because of using spring and zeus at the same time, I'd like to know about it anyway.

@toxaq
Copy link

toxaq commented May 21, 2016

This same error is becoming a major issue for me. I suspect it's a timing issue and as such is going to be very hard to debug and will explain why there is no easy reproduction.

Guard::RSpec failed to achieve its <run_on_modifications>, exception was:
> [#] Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/rspec_guard_result
> [#] /Users/user/.rvm/gems/ruby-2.1.5@example/gems/guard-rspec-4.6.5/lib/guard/rspec/results.rb:11:in `readlines'
> [#] /Users/user/.rvm/gems/ruby-2.1.5@example/gems/guard-rspec-4.6.5/lib/guard/rspec/results.rb:11:in `initialize'

Could we just add an exception handler on line 11 of results? https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec/results.rb#L11

lines = File.readlines(filename) rescue nil

would suffice. I'd rather I got not result info that having to cancel out of zeus, reset my console and start again each time. Thoughts? Happy to add a PR for this if it's useful.

@e2
Copy link
Contributor

e2 commented May 21, 2016

@toxaq - I'd really like to fix this if I can reproduce it.

lines = File.readlines(filename) rescue nil

Something like this was used long ago. It created issues almost impossible to debug, because "something didn't work".

The formatter is responsible for creating the file:

https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec_formatter.rb

And the important question is: what's the ERROR CODE FROM RSPEC?

See: https://github.com/guard/guard-rspec/blob/master/lib/guard/rspec/command.rb#L25

If there are failures, it should be 2. If there's a syntax error, it shouldn't be 2.

Either way this is either a bug in Guard::RSpec or RSpec.

Until I reproduce it, I don't know which is the proper fix for this.

There's no use in silencing an error if it can simply be fixed properly.

@e2
Copy link
Contributor

e2 commented May 21, 2016

@toxaq - notice you don't have a full absolute path to the file: tmp/rspec_guard_result

See the EXACT recipe from @ryankc33 - it expands the path in both cases. If you don't have the path expanded, it's a Zeus issue related to the environment not being passed.

@e2
Copy link
Contributor

e2 commented May 22, 2016

For anyone else with this issue:

  1. Run bundle exec guard -d to get the full command line passed to RSpec
  2. Run that exact command and check the error code (it should be 0 on success, 2 when specs fail, and something totally different if there's a syntax error)

The code responsible for handling this is here:

https://github.com/guard/guard-rspec/blob/e907de5/lib/guard/rspec/rspec_process.rb#L30

(The file is only supposed to be read when RSpec returns 0 or 2).

@toxaq
Copy link

toxaq commented May 22, 2016

There's no use in silencing an error if it can simply be fixed properly.

This fix means I can keep using guard. I've forked this temporarily to try it and so far so good.

Something like this was used long ago.

I'm not advocating burying an exception, I'm advocating logging out the error. You'd get more helpful feedback if a warning asked for this info at point of error instead of crashing terminal.

@e2
Copy link
Contributor

e2 commented May 22, 2016

@toxaq - just give me the error code from RSpec. If it's an RSpec bug, it's best if it's fixed before 3.5.0 is released.

Just spend a few minutes to just confirm that the error code is 2 and give a traceback from RSpec. (So I can at least simulate it and create a workaround in guard-rspec).

Also, it's a bug if you're getting a relative path, because it means a chdir in your app can break stuff.

I want to address this soon (new Guard::RSpec release), so please help me out since I can't reproduce this and "guessing" is just a waste of time if I get it wrong.

If you can reproduce it it also means you're the one that can confirm the fix. If you can't find time to confirm it, I can't confidently release a fix if I can't reproduce it myself. If you just fork and ignore the issue, other people may have the same problem, even if I "fix something" and fix something unrelated to your exact scenario.

@toxaq
Copy link

toxaq commented May 22, 2016

What error code? I get this crash on a second run of some passing tests at random. I can run the entire suite from rspec console with no errors. This error is entirely random for me and is probably why no-one can make a reproducible test case. Happy to help find this error code but I don't know where to start.

@e2
Copy link
Contributor

e2 commented May 22, 2016

Add a STDERR.puts exit_code.inspect before this line:

https://github.com/guard/guard-rspec/blob/e907de5/lib/guard/rspec/rspec_process.rb#L29

The point is: even if you're running Zeus (which may be related), RSpec should not return 2 without dumping the results for Guard::RSpec to read.

So I could at least get a sense of what's wrong if I knew that error code you're getting when the file isn't found.

I can quick-release a version of RSpec to debug (and perhaps even fix) this, but I at least need to know that error code before I try anything.

@e2
Copy link
Contributor

e2 commented May 22, 2016

@toxaq - I've released v4.7.0 with extensive debugging added, so if you can reproduce the problem there, just open a new issue with the output of bundle exec guard -d.

That should give me enough info to solve this if it still occurs.

In short, Guard::RSpec must crash if the file doesn't exist, because it means there's a bad bug somewhere that shouldn't be ignored. If that's the case it should be reported, fixed and released ASAP so people can continue work without workarounds, forking or digging.

@e2 e2 added the bug label May 22, 2016
@e2 e2 added the zeus label May 22, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants