简体   繁体   中英

bash: syntax error near unexpected token `&' in Visual Studio Code

VS Code is using this command to activate my venv:

$ & d:/Documents/TRIS/venv/Scripts/Activate.ps1

instead of

source "D:/Documents/MY_EXP/env/Scripts/activate"

Due to the '&' symbol is this command, i catch this error:

bash: syntax error near unexpected token `&'

xx

So i have to activate it with "source" command by my hands:

source "D:/Documents/MY_EXP/env/Scripts/activate"

Trying to run my python file I have the same error on console:

xx

The & symbol is not the part of the paths, this is the part of command. I tried to open other folders too, but the & symbol is everywhere...

UPD I have realised the bash console works correctly in a random way. Sometimes when i open my projects env activates with source. But when i kill terminal and open the new one - ampersand appears. But bash terminal called "Python" still have ampersand in it when i try to run file with activated env.

From a similar question , I found this answer :

Root cause is vscode.env.shell doesn't honor what you set in terminal.integrated.defaultProfile ... It looks vscode team has fixed that (but not released into stable version)

Looks like the root cause is a bug with VSCode environment variables and it's already fixed in VSCode Insiders edition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM