简体   繁体   English

bash:Visual Studio Code 中意外标记“&”附近的语法错误

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

VS Code is using this command to activate my venv: VS Code 正在使用这个命令来激活我的 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:尝试运行我的 python 文件我在控制台上遇到了同样的错误:

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. UPD 我已经意识到 bash 控制台以随机方式正常工作。 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.但是当我尝试使用激活的环境运行文件时,名为“Python”的 bash 终端中仍然有与号。

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)根本原因是vscode.env.shell不遵守您在terminal.integrated.defaultProfile中设置的内容...看起来 vscode 团队已修复该问题(但未发布到稳定版本)

Looks like the root cause is a bug with VSCode environment variables and it's already fixed in VSCode Insiders edition.看起来根本原因是 VSCode 环境变量的错误,并且已经在 VSCode Insiders 版本中修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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