-
Notifications
You must be signed in to change notification settings - Fork 127
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
Fix ENOENT error when readline is not loaded #1073
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
lazyatom
changed the title
Fix ENOENT error when running tests under Rails
Fix ENOENT error when readline is not loaded
Jan 31, 2024
I have updated the description with some comments that I think more clearly identify the situation where this issue occurs -- it's nothing to do with Rails, and only occurs when the compiled Readline library cannot be loaded. This is the default case on a new Ruby 3.3 installation, because the |
Under Ruby 3.3, without this change, running tests under Rails using the `bin/rails test` command fails. The failure can be expressed in two ways. If a whole test file is being run (e.g. `bin/rails test test/models/thing_test.rb`, then it looks like the whole contents of the file are being passed to rdbg: ``` (rdbg) nil (rdbg) (rdbg) false (rdbg) (rdbg) eval error: (rdbg)//private/tmp/thing/test/models/thing_test.rb:1: syntax error, unexpected end-of-input, expecting ';' or '\n' ...gTest < ActiveSupport::TestCase ... ^ nil (rdbg) eval error: (rdbg)//private/tmp/thing/test/models/thing_test.rb:1: syntax error, unexpected end-of-input test "stuff" do ^ nil (rdbg) #<ThingTest:0x000000012409ebe0> (rdbg) true (rdbg) eval error: (rdbg)//private/tmp/thing/test/models/thing_test.rb:1: syntax error, unexpected `end' nil (rdbg) eval error: (rdbg)//private/tmp/thing/test/models/thing_test.rb:1: syntax error, unexpected `end' nil (rdbg) Really quit? [Y/n] ``` If a specific line is passed (e.g. `bin/rails test test/models/thing.rb:4`), then the failure is different: ``` (rdbg) #<Thread:0x000000011eae9c40@DEBUGGER__::SESSION@server /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:179 run> terminated with exception (report_on_exception is true): /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets': No such file or directory @ rb_sysopen - test/models/thing_test.rb:6 (Errno::ENOENT) from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `readline' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:78:in `block in readline' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:90:in `block in setup_interrupt' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:1981:in `intercept_trap_sigint' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:83:in `setup_interrupt' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:77:in `readline' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:444:in `wait_command' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:404:in `block in wait_command_loop' from <internal:kernel>:187:in `loop' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:403:in `wait_command_loop' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:329:in `process_event' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:254:in `session_server_main' from /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:212:in `block in activate' nil #<Errno::ENOENT: No such file or directory @ rb_sysopen - test/models/thing_test.rb:6> @@@ #<Thread:0x0000000102a5b308 run> > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1251:in `backtrace' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1251:in `block in wait_next_action_' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1249:in `each' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1249:in `rescue in wait_next_action_' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1244:in `wait_next_action_' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:875:in `block in wait_next_action' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:866:in `block in fiber_blocking' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:866:in `blocking' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:866:in `fiber_blocking' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:875:in `wait_next_action' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:320:in `suspend' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:251:in `on_breakpoint' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/breakpoint.rb:69:in `suspend' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/breakpoint.rb:170:in `block in setup' > /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:2633:in `debugger' > /private/tmp/thing/test/models/thing_test.rb:7:in `block in <class:ThingTest>' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:94:in `block (3 levels) in run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:191:in `capture_exceptions' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:89:in `block (2 levels) in run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:303:in `time_it' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:88:in `block in run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:412:in `on_signal' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:239:in `with_info_handler' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest/test.rb:87:in `run' > /Users/james/.gem/ruby/3.3.0/gems/activesupport-7.1.3/lib/active_support/executor/test_helper.rb:5:in `block in run' > /Users/james/.gem/ruby/3.3.0/gems/activesupport-7.1.3/lib/active_support/execution_wrapper.rb:105:in `perform' > /Users/james/.gem/ruby/3.3.0/gems/activesupport-7.1.3/lib/active_support/executor/test_helper.rb:5:in `run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:1126:in `run_one_method' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:378:in `run_one_method' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:365:in `block (2 levels) in run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:364:in `each' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:364:in `block in run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:412:in `on_signal' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:399:in `with_info_handler' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:363:in `run' > /Users/james/.gem/ruby/3.3.0/gems/railties-7.1.3/lib/rails/test_unit/line_filtering.rb:10:in `run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:185:in `block in __run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:185:in `map' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:185:in `__run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:162:in `run' > /Users/james/.gem/ruby/3.3.0/gems/minitest-5.21.2/lib/minitest.rb:86:in `block in autorun' @@@ #<Thread:0x00000001200d30d8 /Users/james/.gem/ruby/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb:42 sleep> > /Users/james/.gem/ruby/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb:48:in `sleep' > /Users/james/.gem/ruby/3.3.0/gems/activerecord-7.1.3/lib/active_record/connection_adapters/abstract/connection_pool/reaper.rb:48:in `block in spawn_thread' ["DEBUGGER Exception: /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/thread_client.rb:1255", #<Errno::ENOENT: No such file or directory @ rb_sysopen - test/models/thing_test.rb:6>, ["/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `readline'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:78:in `block in readline'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:90:in `block in setup_interrupt'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:1981:in `intercept_trap_sigint'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:83:in `setup_interrupt'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:77:in `readline'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:444:in `wait_command'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:404:in `block in wait_command_loop'", "<internal:kernel>:187:in `loop'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:403:in `wait_command_loop'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:329:in `process_event'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:254:in `session_server_main'", "/Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:212:in `block in activate'"]] E Error: ThingTest#test_stuff: Errno::ENOENT: No such file or directory @ rb_sysopen - test/models/thing_test.rb:6 /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `gets' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/console.rb:146:in `readline' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:78:in `block in readline' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:90:in `block in setup_interrupt' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:1981:in `intercept_trap_sigint' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:83:in `setup_interrupt' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/local.rb:77:in `readline' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:444:in `wait_command' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:404:in `block in wait_command_loop' <internal:kernel>:187:in `loop' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:403:in `wait_command_loop' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:329:in `process_event' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:254:in `session_server_main' /Users/james/.gem/ruby/3.3.0/gems/debug-1.9.1/lib/debug/session.rb:212:in `block in activate' ``` Either way, making this change seems to fix it. The error is very reminiscent of that described in ruby#156, where a similar fix was required.
thanks! |
xjunior
referenced
this pull request
in powerhome/audiences
Apr 8, 2024
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [debug](https://togithub.com/ruby/debug) | `1.9.1` -> `1.9.2` | [![age](https://developer.mend.io/api/mc/badges/age/rubygems/debug/1.9.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/rubygems/debug/1.9.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/rubygems/debug/1.9.1/1.9.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/rubygems/debug/1.9.1/1.9.2?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>ruby/debug (debug)</summary> ### [`v1.9.2`](https://togithub.com/ruby/debug/releases/tag/v1.9.2) [Compare Source](https://togithub.com/ruby/debug/compare/v1.9.1...v1.9.2) #### What's Changed - config - Make irb_console toggleable with config update by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1057](https://togithub.com/ruby/debug/pull/1057) - internal - Stop assuming Array#each is written in C by [@​k0kubun](https://togithub.com/k0kubun) in [https://github.com/ruby/debug/pull/1061](https://togithub.com/ruby/debug/pull/1061) - Add `base64` gem to the dependencies by [@​y-yagi](https://togithub.com/y-yagi) in [https://github.com/ruby/debug/pull/1066](https://togithub.com/ruby/debug/pull/1066) - Support Ruby 3.4's new error message format by [@​hsbt](https://togithub.com/hsbt) in [https://github.com/ruby/debug/pull/1080](https://togithub.com/ruby/debug/pull/1080) - catch up ruby 3.4.0 error related changes by [@​ko1](https://togithub.com/ko1) in [https://github.com/ruby/debug/pull/1083](https://togithub.com/ruby/debug/pull/1083) - Fix syntax warnings by [@​casperisfine](https://togithub.com/casperisfine) in [https://github.com/ruby/debug/pull/1072](https://togithub.com/ruby/debug/pull/1072) - Drop base64 dependency by [@​Earlopain](https://togithub.com/Earlopain) in [https://github.com/ruby/debug/pull/1071](https://togithub.com/ruby/debug/pull/1071) - Fix ENOENT error when readline is not loaded by [@​lazyatom](https://togithub.com/lazyatom) in [https://github.com/ruby/debug/pull/1073](https://togithub.com/ruby/debug/pull/1073) - Remove and Restore irb configuration like irbrc while irb console tests by [@​hsbt](https://togithub.com/hsbt) in [https://github.com/ruby/debug/pull/1067](https://togithub.com/ruby/debug/pull/1067) - Use rb_iseqw_to_iseq to get iseq pointer by [@​peterzhu2118](https://togithub.com/peterzhu2118) in [https://github.com/ruby/debug/pull/1093](https://togithub.com/ruby/debug/pull/1093) - tests - Add Ruby 3.3 to CI matrix by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1058](https://togithub.com/ruby/debug/pull/1058) - Use ruby/actions workflow for ruby versions by [@​m-nakamura145](https://togithub.com/m-nakamura145) in [https://github.com/ruby/debug/pull/1065](https://togithub.com/ruby/debug/pull/1065) - Separate setup and execution steps in CI by [@​ono-max](https://togithub.com/ono-max) in [https://github.com/ruby/debug/pull/1088](https://togithub.com/ruby/debug/pull/1088) - Fix flakey test "test_reponse_returns_correct_threads_info" by [@​ono-max](https://togithub.com/ono-max) in [https://github.com/ruby/debug/pull/1089](https://togithub.com/ruby/debug/pull/1089) - Add Launchable in CI by [@​ono-max](https://togithub.com/ono-max) in [https://github.com/ruby/debug/pull/1090](https://togithub.com/ruby/debug/pull/1090) - doc - Correct the irb command's description by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1056](https://togithub.com/ruby/debug/pull/1056) - Fix prelude doc example to use curly braces by [@​adam12](https://togithub.com/adam12) in [https://github.com/ruby/debug/pull/1052](https://togithub.com/ruby/debug/pull/1052) - Mention IRB console in readme by [@​st0012](https://togithub.com/st0012) in [https://github.com/ruby/debug/pull/1092](https://togithub.com/ruby/debug/pull/1092) #### New Contributors - [@​Earlopain](https://togithub.com/Earlopain) made their first contribution in [https://github.com/ruby/debug/pull/1071](https://togithub.com/ruby/debug/pull/1071) - [@​lazyatom](https://togithub.com/lazyatom) made their first contribution in [https://github.com/ruby/debug/pull/1073](https://togithub.com/ruby/debug/pull/1073) - [@​m-nakamura145](https://togithub.com/m-nakamura145) made their first contribution in [https://github.com/ruby/debug/pull/1065](https://togithub.com/ruby/debug/pull/1065) **Full Changelog**: ruby/debug@v1.9.1...v1.9.2 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/powerhome/audiences). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNjkuMiIsInVwZGF0ZWRJblZlciI6IjM3LjI2OS4yIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Update -- I believe this error has nothing to do with Rails, but was exposed because my version of Ruby 3.3 did not have readline built properly. When readline could not be loaded, it falls back to the code which calls
gets
, and if there is a filename in ARGV, it will try to load that file as input tordbg
. I think the fix remains -- it's the same as #156A simple way to replicate it would be to move
readline.so
out of the way in your local ruby installation, and then with the programm intest.rb
:then run this ensuring there's a file path in ARGV, e.g.
ruby test.rb
. This should hit the error.Further update -- I think this may ultimately be because the
readline-ext
gem is no longer bundled as of Ruby 3.3 (https://bugs.ruby-lang.org/issues/19616); this means that by default,readline.so
(orreadline.bundle
) will not load, and we will hit this code path.Original report message:
Under Ruby 3.3, without this change, running tests under Rails (7.1.3) using the
bin/rails test
command fails.Either way, making this change seems to fix it. The error is very reminiscent of that described in #156, where a similar fix was required.
I apologise but I am not sure how to express this failure in a test, but I can confirm that the build does not fail under Ruby 3.3 either with or without my proposed change.
I should say that I'm running this on an M1 Pro processor, and I have a colleague using an Intel mac who cannot replicate this, so perhaps that's involveD?
The failure can be expressed in two ways. If a whole test file is being run (e.g.
bin/rails test test/models/thing_test.rb
, then it looks like the whole contents of the file are being passed to rdbg:If a specific line is passed (e.g.
bin/rails test test/models/thing.rb:4
), then the failure is different: