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

& was unexpected at this time. when running python on new vscode terminal setting #16252

Closed
xuke444 opened this issue May 15, 2021 · 2 comments
Closed
Labels
bug Issue identified by VS Code Team member as probable bug

Comments

@xuke444
Copy link

xuke444 commented May 15, 2021

Environment data

  • VS Code version: 1.56.2
  • Extension version (available under the Extensions sidebar): 2021.5.842923320
  • OS and version: windows10
  • Python version (& distribution if applicable, e.g. Anaconda): 3.8
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): n/a
  • Relevant/affected Python packages and their versions: n/a
  • Relevant/affected Python-related VS Code extensions and their versions: n/a
  • Value of the python.languageServer setting: Microsoft

[NOTE: If you suspect that your issue is related to the Microsoft Python Language Server (python.languageServer: 'Microsoft'), please download our new language server Pylance from the VS Code marketplace to see if that fixes your issue]

Expected behaviour

when I run python from vscode it gives me an error
& was unexpected at this time.

it seems related to the new way that vscode handle the terminal setting
it is "terminal.integrated.defaultProfile.windows": "Command Prompt"

Actual behaviour

if I switch to "terminal.integrated.shell.windows": "c:\windows\System32\cmd.exe" in vscode settings
it works fine
however vs code mark this setting be deprecated, eventually there will be no way to avoid this issue.

Steps to reproduce:

open vscode, edit settings in json delete "terminal.integrated.shell.windows" if any
then use vscode menu to select "Termnal:Select Default Termnal" to select "command prompt" (git bash, or power have same issue)
Then run any python file.
Conda activate works, but then second line to call python pops above error.

@xuke444 xuke444 added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels May 15, 2021
@alexitx
Copy link

alexitx commented May 16, 2021

Same issue with Git Bash as I'm using it everywhere - bash: syntax error near unexpected token `&'.

terminal.integrated.defaultProfile.windows uses the default activation command for PowerShell. The only workaround I'm using is also terminal.integrated.shell.windows.

This is occurring since VSCode 1.56 I believe where default terminal profiles were added.

@karthiknadig
Copy link
Member

Duplicate of #16175

@karthiknadig karthiknadig marked this as a duplicate of #16175 May 18, 2021
@karthiknadig karthiknadig removed the triage-needed Needs assignment to the proper sub-team label May 24, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 22, 2021
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
Projects
None yet
Development

No branches or pull requests

3 participants