Open johnvictorfs opened 1 year ago
Could you show us the sample program to reproduce this problem?
Sure thing!
Here's a reproduction repo https://github.com/johnvictorfs/vscode-rbdg-issue
In the repo I have setup two different vscode debugging configs, one for the latest version of the extension (v0.1.0) and another one for the old one (v0.0.11), when it used to work fine, with the only changes being the required ones, noted in the comments
rbenv
and ruby 3.1.2
rbenv
active in your shell run bundle install
test.rb
with rdbg
debug settings in the repo using the appropriate version for each debug config (either v0.0.11
or v0.1.0
)Using vscode-rdbg
at v0.0.11
works fine with the following settings as screenshot below shows:
{
"name": "Debug spec (v0.0.11)",
"type": "rdbg",
"request": "launch",
"useBundler": false,
"script": "${relativeFile}",
"rdbgPath": "PATH=$HOME/.rbenv/shims:$PATH bin/rdbg",
"command": "rspec",
"cwd":"${workspaceFolder}",
"env": {
"PATH": "${env:PATH}"
}
}
Now, if I update to latest version of the extension, my old settings break because of PATH=$HOME/.rbenv/shims:$PATH
, which I needed to load rbenv
properly, so it stops working with the almost same setting below (except forced changes shown by the comments)
{
"name": "Debug spec (v0.1.0)",
"type": "rdbg",
"request": "launch",
"useBundler": false,
"script": "${relativeFile}",
"rdbgPath": "bin/rdbg", // necessary on v0.1.0, but doesn't work
"command": "rspec",
"cwd":"${workspaceFolder}",
"useTerminal": true, // required to see proper error traceback
"env": {
"PATH": "${env:PATH}"
}
}
Below is what happens if I try to run the old launch.json
config, with the latest extension version:
@johnvictorfs
Thank you! To clarify the problem, let me ask one question:
Does it work with the following launch.json?
{
"name": "Debug spec (v0.1.0)",
"type": "rdbg",
"request": "launch",
"useBundler": false,
"script": "${relativeFile}",
"rdbgPath": "bin/rdbg", // necessary on v0.1.0, but doesn't work
"command": "rspec",
"cwd":"${workspaceFolder}"
}
Hello @ono-max it does not work
I get the following pop-up error with no logs in the Debug console:
And this is all the Output tab shows:
"Running: bin/rdbg --command --open --stop-at-load -- rspec spec/models/job_spec.rb"
[Start session]
{"d":{},"f":"35074f39-b8b3-435f-9e52-22bdf71948b1","g":"rdbg","h":"Debug spec (v0.1.0)","i":{"uri":{"$mid":1,"fsPath":"/home/john/projects/***","external":"file:///home/john/projects/***","path":"/home/john/projects/***","scheme":"file"},"name":"***","index":0},"j":{"name":"Debug spec (v0.1.0)","type":"rdbg","request":"launch","useBundler":false,"script":"spec/models/job_spec.rb","rdbgPath":"bin/rdbg","command":"rspec","cwd":"/home/john/projects/***","__configurationTarget":6}}
(Some folder names censored)
If I change the settings to the following:
{
"name": "Debug spec (v0.1.0)",
"type": "rdbg",
"request": "launch",
"useBundler": false,
"script": "${relativeFile}",
"rdbgPath": "bin/rdbg", // necessary on v0.1.0, but doesn't work
"command": "rspec",
"useTerminal": true, // Added this setting
"cwd":"${workspaceFolder}"
},
I get some Output for the error:
/usr/lib/ruby/3.0.0/bundler/definition.rb:431:in `validate_ruby!': Your Ruby version is 3.0.5, but your Gemfile specified 3.1.2 (Bundler::RubyVersionMismatch)
from /usr/lib/ruby/3.0.0/bundler/definition.rb:406:in `validate_runtime!'
from /usr/lib/ruby/3.0.0/bundler.rb:164:in `setup'
from /usr/lib/ruby/3.0.0/bundler/setup.rb:20:in `block in <top (required)>'
from /usr/lib/ruby/3.0.0/bundler/ui/shell.rb:159:in `with_level'
from /usr/lib/ruby/3.0.0/bundler/ui/shell.rb:111:in `silence'
from /usr/lib/ruby/3.0.0/bundler/setup.rb:20:in `<top (required)>'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
from bin/rdbg:25:in `<main>'
Error: exit code is 1
Make sure to install rdbg command (`gem install debug`).
If you are using bundler, write `gem 'debug'` in your Gemfile.
Because I have multiple ruby versions installed, I use Rbenv to manage them between projects, and the extension just tries to use the system one, and my workaround I used to load Rbenv before stopped working
I do think, however, that this open PR would fix my issue https://github.com/ruby/vscode-rdbg/pull/113
which shell do you use and how to setup the rbenv on your login shell?
Zsh, I setup my rbenv with this:
if [ -x "$(command -v rbenv)" ]; then
eval "$(rbenv init -)"
fi
@johnvictorfs
Sorry for waiting for you. Could you try v0.2.0 when having time?
I have been using the following config for this extension (and some other similar ones) for a couple of months, with a workaround to load rbenv so it doesn't use my system ruby version/gems:
Using
"rdbgPath": "PATH=$HOME/.rbenv/shims:${PATH} ${workspaceFolder}/bin/rdbg",
no longer works, fails with the message below, without any useful logs in the 'Output' tab:It now requires me to use
"rdbgPath": "${workspaceFolder}/bin/rdbg",
, which doesn't load rbenv, tries to use my system ruby and breaksI have also tried the following config, also with no success (same error):
Using
"useBundler": true
with any of the config variations above also fails, with same error messages, even when specifying abundlePath
Any way I can fix this? I could probably setup some setting in my shell to pre-load rbenv but I would like a solution that stays self-contained in the VsCode config, so I don't need to have everyone in my company manually fix this issue in their systems