Search code examples
bashgitvisual-studio-codeunexpected-token

Git Bash error in VS code unexpected token '&'


I'm a beginner and I'm getting a bash syntax error Unexpected token '&'

Initially, I was getting this error while using a virtual environment in python. But today I cleaned my PC and reinstalled the window and now I can't even run normal programs.

Cause of Error -> I'm using VS Code and terminal as Git Bash.

After wasting days I got to know that this is happening because Bash and PowerShell have different syntax and when I'm running the code the vs code is not adapting to bash's syntax (and yes it works on PowerShell).

And Default terminal is also set to Git Bash in my JSON setting file like this: "terminal.integrated.defaultProfile.windows": "Git Bash",

I tried changing to another famous way: "terminal.integrated.shell.windows":"path_here" and it does not work either and says deprecated method.

How can I change the default Syntax of vs code terminal? Do I have to reinstall the bash and change something in my options? And I was using bash b4 as well but never faced this issue but then I recently started using virtual env then this error occurred for the first time. So I'm confused whether this is an in-built problem or something that I can fix? And I found many ppl with the same type of question (which are posted recently that leads me to think it could be a fault from their side) in StackOverflow but no one was able to define it hence I'm adding this one.


Solution

  • Yes, i was right. The issue was in the VScode itself. Today there was an update and everything seems to be normal/working now.