fix: add onDebugResolve activation event to fix debug adapter not found#176
Open
noahmehl wants to merge 1 commit intoerlang-ls:mainfrom
Open
fix: add onDebugResolve activation event to fix debug adapter not found#176noahmehl wants to merge 1 commit intoerlang-ls:mainfrom
noahmehl wants to merge 1 commit intoerlang-ls:mainfrom
Conversation
Author
|
Actually, this looks like it's needed on Mac anytime you close or re-open Visual Studio Code and you don't have an |
Member
|
Hi @noahmehl and thanks for your contribution. The Erlang LS project and the corresponding VS Code extension is currently deprecated/unmaintained and I would strongly encourage you to look at the ELP project instead: Among other things, the ELP extension provides a much more solid experience than Erlang LS. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When starting an
erlangdebug session without an Erlang file already open in the editor, VS Code reports:The root cause is that
activationEventscurrently only contains"onLanguage:erlang". The debug adapter descriptor factory is registered insideactivate(), so if no.erlfile is open when the debug session starts, the extension has never activated and theerlangdebug type is unregistered.Although VS Code 1.74 introduced implicit activation events for contributed debug types, this does not reliably cover all host environments (e.g. Cursor, older VS Code builds, or remote development contexts).
Affected scenario: relx releases of existing Erlang projects
This issue is most pronounced when debugging an existing OTP project managed with relx. In this workflow the
runinterminalcommand invokes the VM directly rather than opening a source file:{ "name": "Start My App", "type": "erlang", "request": "launch", "cwd": "${workspaceRoot}", "runinterminal": [ "/bin/sh", "-c", "REL=${workspaceFolder}/_build/dev/rel/myapp; VSN=$(awk '{print $2}' $REL/releases/start_erl.data); ERTS_VSN=$(awk '{print $1}' $REL/releases/start_erl.data); cd $REL; ROOTDIR=$REL BINDIR=/path/to/erlang/erts-$ERTS_VSN/bin EMU=beam PROGNAME=myapp /path/to/erlang/erts-$ERTS_VSN/bin/erlexec -boot $REL/releases/$VSN/start -mode embedded -config ${workspaceFolder}/config/sys.config -args_file ${workspaceFolder}/config/vm.args" ], "projectnode": "myapp@hostname", "cookie": "mycookie", "preLaunchTask": "Build Release" }Because
runinterminallaunches the BEAM VM directly (replicating what the relx-generated release script does internally), no.erlfile is opened in the editor.onLanguage:erlangnever fires before the debug adapter is needed. The user must manually open a.erlfile first as a workaround — which is non-obvious and breaks the one-click debug experience.Why call erlexec directly instead of the relx release script?
The relx-generated release binary (
_build/dev/rel/myapp/bin/myapp console) is a shell script wrapper that ultimately callserlexecwith the following key environment and arguments:ROOTDIR$ROOTin the boot script resolves to_build/dev/rel/myapp/lib/*BINDIRbin/dir soerlexeccan findbeam.smpEMU=beam,PROGNAMEerlexec-boot releases/$VSN/startstartwhenappname.bootis absent)-mode embedded-config/-args_fileCalling
erlexecdirectly makes this explicit in the launch config, removes the relx shell script from the chain, and gives the editor a clear Erlang-native entry point for the debug session.Fix
Add
"onDebugResolve:erlang"toactivationEventsinpackage.json:onDebugResolve:erlangis the correct activation event for this case — it fires when VS Code resolves a launch configuration of typeerlang, before the debug adapter is requested, guaranteeing the extension is active whencreateDebugAdapterDescriptoris called.Testing
launch.jsonwith"type": "erlang"and aruninterminalthat starts a relx release node.erlfiles are open in the editorBefore:
Couldn't find a debug adapter descriptor for debug type 'erlang' (extension might have failed to activate)After: debug session starts normally,
els_dapconnects to the running node, and breakpoints can be set in.erlsource files