Add ability to set environment variables when creating a Debug Adapter #56646
Labels
api
debug
Debug viewlet, configurations, breakpoints, adapter issues
feature-request
Request for new features or functionality
on-testplan
Milestone
I currently have Debug Adapter implemented in Ruby language. Ruby has some configuration which is only possible to set via environment variables, such as GEM_HOME.
To get around this I have to write a large Typescript file which spawns my real Debug Adapter in ruby, and then just proxies stdin/stdout between the two. This is awkward, prone to error and quite limited as the debug adapters don't have access to the vscode configuration classes (separate process).
Ideally I should be able to set path, arguments and environment for debug adapter runtime.
Proposed changes
Currently the Debug Adpater runtime configuration only offers runtime path, and arguments, as can been see in;
https://github.com/Microsoft/vscode/blob/master/src/vs/workbench/parts/debug/node/debugAdapter.ts#L299
Note that we cannot configure the spawn options, which is where the environment variables would go. Also other IO options but I'm not as interested in them.
Given that the
DebugAdapterExecutable
class is currently in a proposed state, I would like to add additional functionality to do this now.Proposed changes (pseudo code style!)
And spawn option change
Where
mergeEnvironmentVariables
would take a set of existing env vars (process.env) and then merge the new set of env vars into it.Obviously there will be some other code changes to actually read in the env vars from the extension package.json. Or perhaps only offer this IF implementing via
debugAdapterExecutable
and not via package.json?https://github.com/Microsoft/vscode/blob/e5c3c0f37e993de6a0f8fe6d2ce6596d4e5745ae/src/vs/workbench/parts/debug/common/debug.ts#L424-L427
Other options
Saying that environment should be configured BEFORE you start VSCode isn't always feasible or responsible. That means I can't use different runtimes depending on user settings.
Configuring the runtime environment BEFORE using code for MY debug adapter may break OTHER extensions unexpectedly. Given we're spawning a new process, it is feasible to have the VScode environment setup for Editing and the debug adapter setup for debugging.
The text was updated successfully, but these errors were encountered: