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

Guard::RSpec has just been fired - tmp/rspec_guard_result error #348

Closed
julie-ng opened this issue Nov 25, 2015 · 11 comments
Closed

Guard::RSpec has just been fired - tmp/rspec_guard_result error #348

julie-ng opened this issue Nov 25, 2015 · 11 comments

Comments

@julie-ng
Copy link

I just returned to a project I left off about 4 weeks ago and suddenly have a weird error message when running specs through guard.

If I run bundle exec rspec, everything runs fine without errors.

When I run guard, my tests pass/fail as expected, but I get a giant error that pollutes my console at the end each time:

…
Finished in 2.05 seconds (files took 1.47 seconds to load)
84 examples, 0 failures, 28 pending

Randomized with seed 9631

13:19:09 - ERROR - Guard::RSpec failed to achieve its <run_all>, exception was:
> [#56B29B499E34] Errno::ENOENT: No such file or directory @ rb_sysopen - ./../../tmp/rspec_guard_result
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `readlines'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/results.rb:11:in `initialize'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `new'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:46:in `_read_results'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/rspec_process.rb:17:in `initialize'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `new'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:68:in `_really_run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:57:in `_run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec/runner.rb:34:in `run_all'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:33:in `block in run_all'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:48:in `_throw_if_failed'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-rspec-4.6.4/lib/guard/rspec.rb:33:in `run_all'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:82:in `block in _supervise'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `catch'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:79:in `_supervise'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:22:in `block (3 levels) in run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:119:in `block (2 levels) in _run_group_plugins'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `each'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:117:in `block in _run_group_plugins'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `catch'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:116:in `_run_group_plugins'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:21:in `block (2 levels) in run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:20:in `each'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:20:in `block in run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/lumberjack-1.0.9/lib/lumberjack.rb:32:in `unit_of_work'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/runner.rb:18:in `run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/commander.rb:82:in `run_all'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:42:in `block in _run_actions'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:37:in `each'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:37:in `_run_actions'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/internals/queue.rb:21:in `process'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/commander.rb:43:in `start'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli/environments/valid.rb:16:in `start_guard'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/cli.rb:122:in `start'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:32:in `execute'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/lib/guard/aruba_adapter.rb:19:in `execute!'
> [#56B29B499E34] /Users/julieng/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/guard-2.13.0/bin/_guard-core:11:in `<main>'
13:19:09 - INFO - Guard::RSpec has just been fired
[1] guard(main)>

Note about results_file: I purposely changed the path, so it would output in the right place. I am testing a thor app, which generates files, so I have in my code:

before :all do
  Dir.chdir(fixtures_root)
end

I thought that might be the problem, so I tried adding:

after :all do
  Dir.chdir(project_root)
end

where fixtures_root and project_root are both working helper methods.

Guard/Guard::RSpec still seems to be in the wrong directory because it is creating the tmp/rspec_guard_result file in my fixtures directory.

I tried fixing this by adding results_file: './../../tmp/rspec_guard_result' to my Guardfile, which outputs the file in the correct tmp folder.

But the error remains. Anything else I should be trying?

Gem Versions

I ran bundle update in case something changed after upgrading to El Capitan in recent weeks and have the following versions install:

  • rspec (3.4.0)
  • guard-rspec (4.6.4)
  • guard (2.13.0)
@julie-ng
Copy link
Author

Also, I saw #326 but I don't use zeus so I figure that doesn't apply to me.

@e2
Copy link
Contributor

e2 commented Nov 25, 2015

Generally, using chdir is bad, because then every tool run within the chdir has to rely on absolute paths.

rspec has a :chdir option - but this is mostly for projects which have tests separated into "module" (sub directories), where each module has it's own .rspec config.

And even RSpec config files locations are messed up, because you'd have to have .rspec config files your fixtures_root.

So in general - do everything you can to avoid :chdir. If you want to try and get this working anyway, try and set the results_file to a full path, e.g. in your Guardfile:

rspec_results = File.expand_path('rspec_guard_result')
guard :rspec, results_file: rspec_results do
# (...)

Again, avoid using chdir at all costs (unless you're using it for switching projects to run a different, unrelated tool). Think of 'chdir' as just a method to switch projects (and nothing more specific).

Symlinks may be a better option, depending on what you need.

Otherwise, you can create a small repo with the problem, and I can take a look (otherwise, there's just too much guessing and it's too complex to imagine what could go wrong and how to best fix it).

@e2
Copy link
Contributor

e2 commented Nov 25, 2015

Also, if you really need chdir, try being explicit where you need it, e.g. with:

system("cd #{fixtures_root} && ./scripts/run_my_tool")

which isolates the tool without creating problems in the current project.

If you're testing a thor app, it's best to run it in a separate process anyway (using system). It's a slower but better way to test.

@julie-ng
Copy link
Author

Thank you @e2! Your suggestion to use this in my Guardfile worked for me:

rspec_results = File.expand_path('rspec_guard_result')
guard :rspec, results_file: rspec_results do
# (...)

Thank you also for the chdir tips. I have a static html generator and I still haven't figured out the best way to test output yet. I will consider that when I finally get around to refactoring those specs.

@e2
Copy link
Contributor

e2 commented Nov 25, 2015

Glad to help :)

@vyorkin
Copy link

vyorkin commented Feb 3, 2016

I've got the same error, and I don't use chdir anywhere, btw I'm on rails 5

@e2
Copy link
Contributor

e2 commented Feb 3, 2016

@vyorkin - see this thread for debugging: #359 (First, try and change the name of the output file and see which name is mentioned in the crash).

@vyorkin
Copy link

vyorkin commented Feb 3, 2016

@e2 thanks for a quick response! I will

@alexdean
Copy link

this can also occur if you inadvertently have 2 instances of guard running (in multiple terminals, for instance).

@e2
Copy link
Contributor

e2 commented Apr 15, 2016

@alexdean - it's best to set the results file inside the Guardfile - so that the results file is created within generated temporary directory. That way, every Guard instance will generate a different temporary directory. Or the output file could just have the PID attached.

@alagos
Copy link

alagos commented Feb 15, 2024

Probably unrelated but just as reference, I also got that error

Errno::ENOENT: No such file or directory @ rb_sysopen - tmp/rspec_guard_result

but didn't have to do specifically with guard, as I have this in my Guardfile

guard :rspec, cmd: "bin/rspec"

and that bin/rspec binstub was making some sort of conflict , so I recreated it with

bundle binstubs rspec-core --force

and that fixed my problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants