vscode-ruby-test-adapter
vscode-ruby-test-adapter copied to clipboard
Unable to debug specs
Your environment
vscode-ruby-test-adapterversion: 0.8.0- Ruby version: 2.3.8
- VS Code version: 1.51.1
- Operating System: Ubuntu 18.04 via WSL2 (Windows 10)
- RSpec version: 3.6.0
Expected behavior
Selecting a rspec example group from the test explorer panel and clicking the debug icon should run the example group with debugging enabled.
Actual behavior
I get an popup with the error:
Error while debugging test: SyntaxError: Unexpected end of JSON input
Source: Test Explorer UI (Exension)
In the output panel, if I select Ruby Test Explorer Log I see the following when trying to debug geolocation_utils_spec.rb
[2020-11-23 09:02:23.505] [INFO] Debugging test(s) ["./spec/lib/geolocation_utils_spec.rb"] of /home/cec/core/ruby-projects/agendalugano
[2020-11-23 09:02:23.505] [INFO] Running Ruby tests ["./spec/lib/geolocation_utils_spec.rb"]
[2020-11-23 09:02:23.506] [INFO] Starting the debug session
[2020-11-23 09:02:23.506] [INFO] Running test file: /home/cec/core/ruby-projects/agendalugano/spec/lib/geolocation_utils_spec.rb
[2020-11-23 09:02:23.506] [INFO] Running command: rdebug-ide --host 127.0.0.1 --port 1234 -- $EXT_DIR/debug_rspec.rb --require /home/cec/.vscode-server/extensions/connorshea.vscode-ruby-test-adapter-0.8.0/custom_formatter.rb --format CustomFormatter '/home/cec/core/ruby-projects/agendalugano/spec/lib/geolocation_utils_spec.rb'
[2020-11-23 09:02:23.990] [DEBUG] [CHILD PROCESS OUTPUT] Fast Debugger (ruby-debug-ide 0.7.2, debase 0.2.4.1, file filtering is supported) listens on 127.0.0.1:1234
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] Uncaught exception: cannot load such file -- /debug_rspec.rb
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/rdebug-ide:23:in `load'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/rdebug-ide:23:in `<main>'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/ruby_executable_hooks:24:in `eval'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/ruby_executable_hooks:24:in `<main>'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] /home/cec/.rvm/gems/ruby-2.3.8@agenda/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_load': cannot load such file -- /debug_rspec.rb (LoadError)
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/gems/ruby-debug-ide-0.7.2/lib/ruby-debug-ide.rb:106:in `debug_program'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/gems/ruby-debug-ide-0.7.2/bin/rdebug-ide:193:in `<top (required)>'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/rdebug-ide:23:in `load'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/rdebug-ide:23:in `<main>'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/ruby_executable_hooks:24:in `eval'
[2020-11-23 09:02:24.368] [DEBUG] [CHILD PROCESS OUTPUT] from /home/cec/.rvm/gems/ruby-2.3.8@agenda/bin/ruby_executable_hooks:24:in `<main>'
[2020-11-23 09:02:24.372] [INFO] Child process has exited. Sending test run finish event.
[2020-11-23 09:02:24.403] [DEBUG] Parsing the below JSON:
[2020-11-23 09:02:24.403] [DEBUG]
[2020-11-23 09:02:25.047] [INFO] Debug session ended
[2020-11-23 09:02:25.047] [INFO] Killing currently-running tests.
I apologize in advance if this is a stupid setup mistake on my end, but I'm new to VS Code as a IDE, since before I could work on a linux desktop and I used RubyMine.
This extensions is absolutely amazing! I can't thank you enough for it.
I have the same issue. Here's a log from the Developer Tools if that's any help:
notificationsAlerts.ts:40 Error while debugging test: SyntaxError: Unexpected end of JSON input
onDidChangeNotification @ breadcrumbsModel.ts:39
(anonymous) @ breadcrumbsModel.ts:39
fire @ event.ts:584
addNotification @ notifications.ts:204
notify @ notificationService.ts:88
(anonymous) @ mainThreadLogService.ts:16
_showMessage @ mainThreadLogService.ts:16
$showMessage @ mainThreadLogService.ts:16
_doInvokeHandler @ rpcProtocol.ts:365
_invokeHandler @ rpcProtocol.ts:365
_receiveRequest @ rpcProtocol.ts:306
_receiveOneMessage @ rpcProtocol.ts:174
(anonymous) @ rpcProtocol.ts:105
fire @ event.ts:584
fire @ ipc.net.ts:431
_receiveMessage @ ipc.net.ts:764
(anonymous) @ ipc.net.ts:624
fire @ event.ts:584
acceptChunk @ ipc.net.ts:174
(anonymous) @ ipc.net.ts:174
t @ ipc.net.ts:900
emit @ events.js:223
addChunk @ _stream_readable.js:309
readableAddChunk @ _stream_readable.js:290
Readable.push @ _stream_readable.js:224
onStreamRead @ internal/stream_base_commons.js:181
Can add that I have the same issue using Minitest instead of RSpec.
But then it went away presumably from auto-updates.
~It's back!~
~Does anyone have specific instructions on how to debug the extension? I'd be happy to dig into this.~
Nevermind, there was already a server running on port 1234.
killall ruby
does the trick. And
lsof -i :1234
will find what's using that port on a Mac (or Linux, I think)
@StefanoDeVuono the Contributing section should have everything you need, I think: https://github.com/connorshea/vscode-ruby-test-adapter#contributing
I have this issue as well, with rspec
I've the same problem. How can I solve that?
"SyntaxError: Unexpected end of JSON input"
I use the ruby "debug". It only appears when using all tests in a file single tests are working fine
The problem appear in this function getDebugCommand(debuggerConfig: vscode.DebugConfiguration, args: string)
in this specific line -- ${process.platform == 'win32' ? '%EXT_DIR%' : '$EXT_DIR'}/debug_rspec.rb ${args}
debug_rspec.rb is not the right file to run. You must find the correct file to run.
Setting "rubyTestExplorer.debugCommand": "bundle exec rdebug-ide" resolved this issue for me.
I will try to make a PR but I don't have the bandwidth at the moment. Fix is to change this:
https://github.com/connorshea/vscode-ruby-test-adapter/blob/c3ee793cd332306cbe30d9d30363944c8164d3db/src/rspecTests.ts#L191
from
runTestFile = async (testFile: string, debuggerConfig?: vscode.DebugConfiguration) => new Promise<string>(async (resolve, reject) => {
this.log.info(`Running test file: ${testFile}`);
const spawnArgs: childProcess.SpawnOptions = {
cwd: this.workspace.uri.fsPath,
shell: true
};
to
runTestFile = async (testFile: string, debuggerConfig?: vscode.DebugConfiguration) => new Promise<string>(async (resolve, reject) => {
this.log.info(`Running test file: ${testFile}`);
const spawnArgs: childProcess.SpawnOptions = {
cwd: this.workspace.uri.fsPath,
shell: true,
this.getProcessEnv()
};