vscode-rdbg: On Mac Os, Unable to use my installed ruby, vs code always picks the system one
On Mac OS
I have installed ruby 3.0.2
When I run in my shell and run
which ruby
I get 3.0.2 and when I run
ruby --version I getruby 3.0.2p107 (2021-07-07) [arm64-darwin20]
I launch vs code via the code command line from this shell. If I go into Vs terminal and type the above commands I get the same output.
When I try to debug a .rb file I do not see the debug dialog and instead VS code tries to run the system installed ruby version (2.6.0) and fails:
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:313:in `to_specs': Could not find 'io-console' (~> 0.5) - did find: [io-console-0.4.7] (Gem::MissingSpecVersionError)
Checked in 'GEM_PATH=/Users/me/work/gems', execute `gem env` for more information
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1449:in `block in activate_dependencies'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1438:in `each'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.
I also did try making a launch file and explicitly setting ‘askParameters’: true but I still never get the debug dialog, just this output.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 2
- Comments: 19
I also had a recent regression where VSCode rdbg couldn’t find the correct Ruby (also on macOS Monterey, using rbenv). I solved it by specifying the path to
rdbgspecifically withrdbgPath:and yes, this extension is totally wonderful, thank you!!!
I ran into the same issue and got it working. When using
zsh, it appears that.zshrcfile is not directly loaded in login shells (more on that here). I debugged the initialisation process of the debugger extension, and the error comes from: https://github.com/ruby/vscode-rdbg/blob/9d445b9804e7c2084e7524ae9ae76e5787a4c2b1/src/extension.ts#L332In that particular point, the command
/bin/zsh -l -c 'bundle exec rdbg --util=gen-sockpath'is being executed and it fails showing an error that reports the usage of system Ruby installation.So I tried running a simple
/bin/zsh -l -c 'which bundle'and the result was/usr/bin/bundle, which is not what I was expecting for. Adding a-d(--no-globalrcs) would have solved, but it would require extension changes.As a consequence
$PATHin that shell doesn’t properly contain rbenv shims (checkable with/bin/zsh -l -c 'echo $PATH').The solution for me was adding
eval "$(rbenv init -)"to the.zprofilefile. As an alternative, addingexport PATH="$HOME/.rbenv/bin:$PATH"works as well.Re-reading https://github.com/ruby/vscode-rdbg/issues/13#issuecomment-1249316284 (and man) I understand that
~/.zshrcis only loaded for interactive shellzsh -l -c ...doesn’t load~/.zshrcbut VSCode extension needs to load it. Becausezsh -ldoesn’t run interactive shell.>> ~/.zshrc.I think
zprofileseems better place to put configuration as @arizz96 had wrote.