Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load multiline env var from external file for debugger failed in fish shell #210922

Open
Teo-ShaoWei opened this issue Apr 22, 2024 · 0 comments
Open
Assignees

Comments

@Teo-ShaoWei
Copy link

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.88.1
  • OS Version: macOS Sonoma 14.4.1 (23E224)

https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_load-environment-variables-from-external-file

Steps to Reproduce

Install fish shell and have it working with VS Code. Go to user settings, change "Terminal > Integrated > Default Profile: Osx" to an installed fish shell.

Follow Load environment variables from external file and set up a .env file with a single multiline env var MYENV="foo\nbar".

Create an app.js with console.log(process.env) (not essential to reproduce the bug, just to demonstrate the correct behaviour).

Create the following launch.json configuration:

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "test",
      "type": "node",
      "request": "launch",
      "args": [],
      "cwd": "${workspaceFolder}",
      "program": "${workspaceFolder}/app.js",
      "console": "integratedTerminal",
      "envFile": "${workspaceFolder}/.env",
    },
  ],
}

Expected

The console will log env vars with MYENV shown to be correctly ingested. For example, when using zsh, the correct single command is run till completion:

> cd <<project_folder>> ; /usr/bin/env 'lines=foo
quote> bar' 'NODE_OPTIONS= --require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.js"  --inspect-publish-uid=http' 'VSCODE_INSPECTOR
_OPTIONS=:::{"inspectorIpc":"/var/folders/x3/_z626cj108sdszn1f9bs8b1m0000gn/T/node-cdp.43848-5e183c87-146.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/shaowei/.nvm/version
s/node/v20.10.0/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/var/folders/x3/_z626cj108sdszn1f9bs8b1m0000gn/T/node-debug-callback-576db9a978f1245e"}' /Users/shaowe
i/.nvm/versions/node/v20.10.0/bin/node ./app.js


Debugger attached.
<<env vars printed below>>
{
  ...
  MYENV: 'foo\nbar',
  ...
}
Waiting for the debugger to disconnect...

Actual

The debugger hanged as the \n causes fish shell to run it as 2 separate commands instead. For example the following:

> /usr/bin/env 'lines=foo' 

> bar' 'NODE_OPTIONS= --require "/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/ms-vscode.js-debug/src/bootloader.js"  --inspect-publish-uid=http' 'VSCODE_INSPECTOR_OPT
IONS=:::{"inspectorIpc":"/var/folders/x3/_z626cj108sdszn1f9bs8b1m0000gn/T/node-cdp.43848-03d5fa0a-141.sock","deferredMode":false,"waitForDebugger":"","execPath":"/Users/shaowei/.nvm/versions/no
de/v20.10.0/bin/node","onlyEntrypoint":false,"autoAttachMode":"always","fileCallback":"/var/folders/x3/_z626cj108sdszn1f9bs8b1m0000gn/T/node-debug-callback-7fa737160ba19e11"}' /Users/shaowei/.n
vm/versions/node/v20.10.0/bin/node ./app.js 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants