-
Notifications
You must be signed in to change notification settings - Fork 240
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
Comments
Set it to a custom path to make sure, e.g. That way, if it fails, at least we'll know if the environment variable is passed. |
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. |
@e2 I've taken the following steps and the error is still occuring
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. |
@e2 Here's a vanilla rails repo replicating the issue. |
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. |
@e2 Ok after some hard debugging I've narrowed it down to this line in rspec_process.rb:
During runs that ran without issues, this line would trigger rspec_formatter to dump_summary. Any pointers as to how to proceed? |
It seems that the problem lies not with Guard-rspec but with Zeus. Closing this issue for now. |
If there's any way guard-rspec could've helped debug this, let me know. |
I'm getting this and we make no use of Zeus. |
The problem seems to be when there are syntax errors in some tests. I had some tests that had been converted incorrectly from require "rails_helper"
RSpec.describe CardBalance, type: :model { } When I ran this just using the
Removing the offending (and useless) tests solved the problem for me. |
@suranyami - can you create a small repo to reproduce this so I can kill this bug? I can't seem to reproduce it myself. |
I've started a repo here: 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 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. |
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 |
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. |
One thing: if you're using 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. |
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.
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
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. |
@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. |
For anyone else with this issue:
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). |
This fix means I can keep using guard. I've forked this temporarily to try it and so far so good.
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. |
@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. |
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. |
Add a 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 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. |
@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 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. |
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
and passed the results_file option to guard
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.
The text was updated successfully, but these errors were encountered: