-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
Bye byebug
, hi debug
!
#17010
Bye byebug
, hi debug
!
#17010
Conversation
Hmm, I wonder if instead of the debug dependency we can do (in if RUBY_PATH.to_s.include?("/vendor/portable-ruby/")
$LOAD_PATH.unshift "#{RbConfig::CONFIG["rubylibprefix"]}/gems/#{RbConfig::CONFIG["ruby_version"]}/gems/debug-1.6.3/lib"
end (I'll figure out a way to do this more magically rather than a hardcoded version - maybe on the Portable Ruby side) This does limit it to Portable Ruby only, but for such a niche developer-only feature I'm OK with that given it avoids juggling more native gems. |
Great work @issyl0 and good idea!
Same, as long as it gets a nice error message 👍🏻 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realize this in draft mode, I hope the early feedback doesn't come off as pestering.
Love to see this being investigated!
@Bo98 Did you figure this out? Or can we ship this and do that in the future? Not that it's urgent, of course. |
well, hardcoded version will be fine as it won't change until we update Portable Ruby - the debug gem ships with our Portable Ruby |
Ahh yes I see what you mean. I'll try to get that working later. 👍🏻 |
8fe8515
to
b830b3e
Compare
If anyone's got any suggestions for why this doesn't work with the |
Ah in addition to the |
Oooh, because |
🤔 I don't have an
|
|
That's weird...
but
So I refer once again to the confused dog in the PR description. 😆 |
Ah, right. |
@Bo98 Thanks. Getting there! |
The require in Though we want it to be conditional of |
Thanks for the extra guidance, Bo! I made |
- Byebug was introduced in [2020](#7577) for hooking into tests for debugging. - It does not work anymore in so far as it does not stop at breakpoints when following the instructions to trigger them in tests.
- This processed that we'd requested a debugger, but didn't drop us into a debugging console until I [stopped the stdin disablement](#16708 (comment)). Usage: ``` ❯ git diff diff --git a/Library/Homebrew/test/migrator_spec.rb b/Library/Homebrew/test/migrator_spec.rb index 87fadd5e95..db4700810a 100644 --- a/Library/Homebrew/test/migrator_spec.rb +++ b/Library/Homebrew/test/migrator_spec.rb @@ -69,6 +69,8 @@ RSpec.describe Migrator do tab.source["tap"] = "homebrew/core" tab.write + binding.break + expect do described_class.new(new_formula, "oldname") end.to raise_error(Migrator::MigratorDifferentTapsError) issyl0 at pictor in /opt/homebrew on bye-byebug ❯ brew tests --only=migrator --debug Randomized with seed 59158 1 process for 1 spec, ~ 1 spec per process .==> Relinking newname .==> Unlinking oldname ...==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname ....==> Migrating formula oldname to newname ==> Unlinking oldname ==> Moving oldname versions to /private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/newname ==> Relinking newname ....[67, 76] in ~/migrator_spec.rb 67| tab = Tab.empty 68| tab.tabfile = HOMEBREW_CELLAR/"oldname/0.1/INSTALL_RECEIPT.json" 69| tab.source["tap"] = "homebrew/core" 70| tab.write 71| => 72| binding.break 73| 74| expect do 75| described_class.new(new_formula, "oldname") 76| end.to raise_error(Migrator::MigratorDifferentTapsError) =>#0 block in <top (required)> (3 levels) at ~/migrator_spec.rb:72 #1 [C] BasicObject#instance_exec at /opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/gems/rspec-core-3.13.0/lib/rspec/core/example.rb:263 # and 68 frames (use `bt' command for all frames) (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p # command t # command ta # command tab # command(rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) p tab # command => #<Tab:0x0000000107156be0 @Aliases=[], @arch=nil, @built_as_bottle=false, @built_on={"os"=>"Macintosh", "os_version"=>"macOS 14", "cpu_family"=>"arm_firestorm_icestorm"}, @Compiler=:clang, @homebrew_version="4.2.16-55-gc8f60ec-dirty", @installed_as_dependency=false, @installed_on_request=false, @loaded_from_api=false, @poured_from_bottle=false, @runtime_dependencies=nil, @source={"path"=>nil, "tap"=>"homebrew/core", "tap_git_head"=>nil, "spec"=>"stable", "versions"=>{"stable"=>nil, "head"=>nil, "version_scheme"=>0}}, @source_modified_time=0, @StdLib=nil, @tabfile=#<Pathname:/private/tmp/homebrew-tests-20240403-85464-3uogqr/cellar/oldname/0.1/INSTALL_RECEIPT.json>, @time=nil, @unused_options=[], @used_options=[]> (rdbg@/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/rspec#85464) ```
- This is cleaner than vendoring a whole bunch of new gems and pinning `psych`. - Thanks for the pointer, Bo! - It doesn't work, though? ``` ❯ brew tests --only=migrator --debug Error: cannot load such file -- debug/debug.so Warning: Removed Sorbet lines from backtrace! Rerun with `--verbose` to see the original backtrace /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `require' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:16:in `rescue in <module:DEBUGGER__>' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:13:in `<module:DEBUGGER__>' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/frame_info.rb:3:in `<top (required)>' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `require_relative' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug/session.rb:31:in `<top (required)>' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `require_relative' /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/lib/ruby/gems/3.1.0/gems/debug-1.6.3/lib/debug.rb:3:in `<top (required)>' /opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `require' /opt/homebrew/Library/Homebrew/dev-cmd/tests.rb:48:in `run' /opt/homebrew/Library/Homebrew/brew.rb:89:in `<main>' ```
- This doesn't work still, but now for new reasons. ``` NoMethodError: undefined method `b' for #<Binding:0x0000000107a7e088> binding.b ^^ # ./test/migrator_spec.rb:72:in `block (3 levels) in <top (required)>' ``` and if I add `require "debug"` to the spec_helper again it gives: ``` LoadError: cannot load such file -- debug ``` but, doing a `require "debug"; binding.b` in `migrator_spec` _does_ work. Where is the require coming from where it works some of the time but not through all of the layers we have?
- This will cause the "debug" gem to be required in `spec_helper.rb`, so we can do interactive debugging.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks @issyl0! Only non-blocking feedback is on the hardcoded debug
gem version; feels likely we'll forget to update that when portable Ruby is updated.
ruby_version = RbConfig::CONFIG["ruby_version"] | ||
ruby_path = "#{RbConfig::CONFIG["rubylibprefix"]}/gems/#{ruby_version}" | ||
|
||
$LOAD_PATH.unshift "#{ruby_path}/extensions/#{Gem::Platform.local}/#{ruby_version}-static/debug-1.6.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be nice to glob or use a Gem
method here so the version isn't hardcoded.
@@ -38,6 +37,8 @@ | |||
|
|||
require_relative "../global" | |||
|
|||
require "debug" if ENV["HOMEBREW_DEBUG"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i wonder if we should just do this for any command run with --debug
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unlike brew tests
which is a developer-only command, we ask end users to run --debug
and we do not want this behaviour for them. Or if we do then it should catch a LoadError
and fail silently.
Thanks @issyl0, great work! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?debug
gem, from theruby/debug
repository, supports our version of Ruby and is "official".psych
, which smarter people than me worked out that we don't support - but if we pin it to an earlier version then it works..gitignore
etc, otherwise this diff was massive and we don't need +80k lines.But the (minimal, basic) testing I did seems to drop me at a prompt that I can use.