File tree Expand file tree Collapse file tree 4 files changed +34
-6
lines changed
Expand file tree Collapse file tree 4 files changed +34
-6
lines changed Original file line number Diff line number Diff line change 33 "configurations" : [
44 {
55 "type" : " rdbg" ,
6- "name" : " Attach with rdbg" ,
6+ "name" : " Debug Homebrew command" ,
7+ "request" : " launch" ,
8+ "rdbgPath" : " ${workspaceFolder}/Library/Homebrew/shims/gems/rdbg" ,
9+ "command" : " brew debugger --" ,
10+ "script" : " ${fileBasenameNoExtension}" ,
11+ "askParameters" : true
12+ },
13+ {
14+ "type" : " rdbg" ,
15+ "name" : " Attach to Homebrew debugger" ,
716 "request" : " attach" ,
8- "rdbgPath" : " ${workspaceFolder}/Library/Homebrew/vendor/portable-ruby/current/lib/ruby/ gems/3.3.0/gems/debug-1.9.1/exe /rdbg" ,
17+ "rdbgPath" : " ${workspaceFolder}/Library/Homebrew/shims/ gems/rdbg" ,
918 "env" : {
1019 "TMPDIR" : " /private/tmp/" ,
1120 }
Original file line number Diff line number Diff line change @@ -11,8 +11,6 @@ class Debugger < AbstractCommand
1111 To pass flags to the command, use `--` to separate them from the `brew` flags.
1212 For example: `brew debugger -- list --formula`.
1313 EOS
14- switch "-s" , "--stop" ,
15- description : "Stop at the beginning of the script."
1614 switch "-O" , "--open" ,
1715 description : "Start remote debugging over a Unix socket."
1816
@@ -28,14 +26,17 @@ def run
2826 end
2927
3028 brew_rb = ( HOMEBREW_LIBRARY_PATH /"brew.rb" ) . resolved_path
31- nonstop = "1" unless args . stop?
3229 debugger_method = if args . open?
3330 "open"
3431 else
3532 "start"
3633 end
3734
38- with_env RUBY_DEBUG_NONSTOP : nonstop , RUBY_DEBUG_FORK_MODE : "parent" do
35+ env = { }
36+ env [ :RUBY_DEBUG_FORK_MODE ] = "parent"
37+ env [ :RUBY_DEBUG_NONSTOP ] = "1" unless ENV [ "HOMEBREW_RDBG" ]
38+
39+ with_env ( **env ) do
3940 system ( *HOMEBREW_RUBY_EXEC_ARGS ,
4041 "-I" , $LOAD_PATH. join ( File ::PATH_SEPARATOR ) ,
4142 "-rdebug/#{ debugger_method } " ,
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ export HOMEBREW_RDBG=" 1"
4+
5+ HOMEBREW_PORTABLE_RUBY_BIN=" $( cd " $( dirname " $0 " ) " /../../ && pwd) /vendor/portable-ruby/current/bin/"
6+ exec " ${HOMEBREW_PORTABLE_RUBY_BIN} " rdbg " $@ "
Original file line number Diff line number Diff line change @@ -258,6 +258,18 @@ then
258258 FILTERED_ENV+=(" ${VAR} =${! VAR} " )
259259 done
260260fi
261+
262+ if [[ -n " ${HOMEBREW_RDBG:- } " ]]
263+ then
264+ for VAR in " ${! RUBY_DEBUG_@ } "
265+ do
266+ # Skip if variable value is empty.
267+ [[ -z " ${! VAR:- } " ]] && continue
268+
269+ FILTERED_ENV+=(" ${VAR} =${! VAR} " )
270+ done
271+ fi
272+
261273unset VAR ENV_VAR_NAMES
262274
263275exec /usr/bin/env -i " ${FILTERED_ENV[@]} " /bin/bash -p " ${HOMEBREW_LIBRARY} /Homebrew/brew.sh" " $@ "
You can’t perform that action at this time.
0 commit comments