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

Special symbols in .env file issue #50302

Closed
osya opened this issue May 22, 2018 · 6 comments
Closed

Special symbols in .env file issue #50302

osya opened this issue May 22, 2018 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded

Comments

@osya
Copy link

osya commented May 22, 2018

  • VSCode Version: 1.23.1
  • OS Version: Windows 10 Pro x64

When you use .env file in the VS Code project and CMD.exe as terminal ("terminal.integrated.shell.windows": "cmd.exe") then for settings environment variables generated commands such as cmd /C "set "SECRET_KEY=uh_p8w$eo6%%tf5)d43b2y))88qxf2t9-s=osvq46u#3ya^p+" without escaping special symbols. Special symbols (such as & and ^) in the values of environment variables from the .env file in the set command should be escaped with the ^ symbol.

Steps to Reproduce:

  1. Create .env file with the following content SECRET_KEY=uh_p8w$eo6%%tf5)d43b2y))88qxf2&t9-s=osvq46u#3ya^p+
  2. Create some .py file
  3. Create launch configuration for Python and ensure "envFile": "${workspaceFolder}/.env" in it (.env file used by default, so may be adding this line is not necessary)
  4. Start debugging

In the Terminal the following error appears:

>cd c:\Users\info_000\Desktop && cmd /C "set "SECRET_KEY=uh_p8w$eo6%%tf5)d43b2y))88qxf2&t9-s=osvq46u#3ya^p+" && set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && python ...\.vscode\extensions\ms-python.python-2018.4.0\pythonFiles\PythonTools\visualstudio_py_launcher.py ...\Desktop 52380 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput ...\Desktop\.vscode\launch.json "
't9-s' is not recognized as an internal or external command,
operable program or batch file.

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

@vscodebot vscodebot bot added the terminal Integrated terminal issues label May 22, 2018
@Tyriar Tyriar added the *caused-by-extension Issue identified to be caused by an extension label May 22, 2018
@Tyriar
Copy link
Member

Tyriar commented May 22, 2018

@vscodebot
Copy link

vscodebot bot commented May 22, 2018

This issue is caused by an extension, please file it with the repository (or contact) the extension has linked in its overview in VS Code or the marketplace for VS Code. See also our issue reporting guidelines.

Happy Coding!

@vscodebot vscodebot bot closed this as completed May 22, 2018
@osya
Copy link
Author

osya commented May 23, 2018

Open the issue microsoft/vscode-python#1727

@osya
Copy link
Author

osya commented May 23, 2018

@Tyriar , please reopen this issue. As @DonJayamanne said, it is an upstream issue

@DonJayamanne
Copy link
Contributor

@Tyriar
I can confirm this is an issue with VS Code.
We're using the VS Code debugger api to launch the terminal, by passing in the environment variables (object)

const termArgs: DebugProtocol.RunInTerminalRequestArguments = {
                    kind: consoleKind,
                    title: 'Python Debug Console',
                    cwd,
                    args: [command].concat(commandArgs),
                    env
                };
                this.debugSession.runInTerminalRequest(termArgs, 5000, (response) => {

So, its VS Code that's not encoding the variables appropriately when setting them in the terminal.

@Tyriar
Copy link
Member

Tyriar commented May 23, 2018

Oh I see, from this:

>cd c:\Users\info_000\Desktop && cmd /C "set "SECRET_KEY=uh_p8w$eo6%%tf5)d43b2y))88qxf2&t9-s=osvq46u#3ya^p+" && set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1" && python ...\.vscode\extensions\ms-python.python-2018.4.0\pythonFiles\PythonTools\visualstudio_py_launcher.py ...\Desktop 52380 34806ad9-833a-4524-8cd6-18ca4aa74f14 RedirectOutput,RedirectOutput ...\Desktop\.vscode\launch.json "
't9-s' is not recognized as an internal or external command,
operable program or batch file.

It looks like the debugger is sending text to the terminal, it needs to do the proper escaping when doing the set commands.

@Tyriar Tyriar reopened this May 23, 2018
@Tyriar Tyriar assigned weinand and unassigned Tyriar May 23, 2018
@Tyriar Tyriar added debug Debug viewlet, configurations, breakpoints, adapter issues and removed terminal Integrated terminal issues *caused-by-extension Issue identified to be caused by an extension labels May 23, 2018
@weinand weinand added the bug Issue identified by VS Code Team member as probable bug label May 23, 2018
@weinand weinand added this to the September 2018 milestone Sep 18, 2018
@mjbvz mjbvz added the verified Verification succeeded label Sep 27, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants