Debug rspec test with bundle exec
MarcPer opened this issue · 10 comments
I'm able to run Rspec on a given line with the following rdbg
call:
rdbg -c -- bundle exec rspec my_spec.rb:123
I could also make it work within VSCode if I don't use bundler, by using the following launch.json::
{
"type": "rdbg",
"name": "RSpec current line with rdbg",
"useBundler": false,
"command": "rspec",
"request": "launch",
"script": "${file}",
"args": [
"${file}:${lineNumber}"
],
},
However, if I change command
to bundle exec rspec
, I get the following message without much clarification:
Couldn't start debug session. The debuggee process exited with code 0
Is there a way to do it currently? Otherwise, let me know if I should push a PR to make this possible.
Did you put a breakpoint to somewhere you want to stop?
Did you put a breakpoint to somewhere you want to stop?
Yes, and without bundle exec
it works fine.
Thank you. Can you share 'rdbg' information in "OUTPUT" tab?
Sure, here you go:
"Running: rdbg --command --open --stop-at-load -- bundle exec rspec /Users/marcper/my_project/my_spec.rb /Users/marcper/my_project/my_spec.rb:21"
[Start session]
{"d":{},"f":"87107d23-84d9-4499-8869-6cddada117c0","g":"rdbg","h":"RSpec current line with rdbg","i":{"uri":{"$mid":1,"fsPath":"/Users/marcper/my_project","external":"file:///Users/marcper/my_project","path":"/Users/marcper/my_project","scheme":"file"},"name":"my_project","index":0},"j":{"type":"rdbg","name":"RSpec current line with rdbg","useBundler":false,"command":"bundle exec rspec","request":"launch","script":"/Users/marcper/my_project/my_spec.rb","args":["/Users/marcper/my_project/my_spec.rb:21"],"__configurationTarget":6,"rdbgExtensions":["traceInspector"],"rdbgInitialScripts":[]}}
Then there's the error I mentioned in the issue description:
Couldn't start debug session. The debuggee process exited with code 0
The output shows the file name twice in the "Running:"
part, so I also tried changing launch.json
, removing the file name from args
, and moving lineNumber
to script
, like this:
{
"type": "rdbg",
"name": "RSpec current line with rdbg",
"useBundler": false,
"command": "bundle exec rspec",
"request": "launch",
"script": "${file}:${lineNumber}",
"args": []
}
But I get the same error, and the following output:
"Running: rdbg --command --open --stop-at-load -- bundle exec rspec /Users/marcper/my_project/my_spec.rb:21"
[Start session]
{"d":{},"f":"6f186413-d5e7-4e6c-8ff4-caaf3366c97a","g":"rdbg","h":"RSpec current line with rdbg","i":{"uri":{"$mid":1,"fsPath":"/Users/marcper/my_project","external":"file:///Users/marcper/my_project","path":"/Users/marcper/my_project","scheme":"file"},"name":"my_project","index":0},"j":{"type":"rdbg","name":"RSpec current line with rdbg","useBundler":false,"command":"bundle exec rspec","request":"launch","script":"/Users/marcper/my_project/my_spec.rb:21","args":[],"__configurationTarget":6,"rdbgExtensions":["traceInspector"],"rdbgInitialScripts":[]}}
I can confirm this issue.
Using just rspec
works but bundle exec rspec
does not
"name": "Debug Rspec with current file",
"type": "rdbg",
"request": "launch",
"command": "rspec",
"script": "${file}",
"useBundler": true,
"args": []
I can confirm this issue. Using just
rspec
works butbundle exec rspec
does not
Good point, I hadn't realized the issue is with RSpec+bundle generally, I thought it was associated with running a specific spec line. I'm changing the issue title.
Have you tried "rdbgPath": "bundle exec rdbg",
in your config file?
This is my current setup which works for me.
Have you tried
"rdbgPath": "bundle exec rdbg",
in your config file?This is my current setup which works for me.
That is odd, this fails for me with spawn bundle exec rdbg ENOENT
, implying rdbgPath
is expected to be just a file path.
This tipped me off from the README:
- useBundler:
- Execute Ruby programs with bundle exec if command configuration is not given
The config that works for me is then
{
"type": "rdbg",
"name": "RSpec current line with rdbg",
"useBundler": true,
"request": "launch",
"script": "/usr/local/bundle/bin/rspec",
"args": ["${file}:${lineNumber}"],
},
The config that works for me is then
{ "type": "rdbg", "name": "RSpec current line with rdbg", "useBundler": true, "request": "launch", "script": "/usr/local/bundle/bin/rspec", "args": ["${file}:${lineNumber}"], },
This did not work for me, but it got me in the right track. I generated the RSpec binstub with bundle binstubs rspec-core
, then the following configuration worked:
{
"type": "rdbg",
"name": "RSpec current line with rdbg",
"request": "launch",
"useBundler": true,
"script": "./bin/rspec",
"args": [
"${file}:${lineNumber}"
],
},