Git Bash error in VS code unexpected token '&' - bash

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.

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

But today I cleaned my pc and reinstalled the window and now i can't even run normal programs.
Make sure your %PATH% environment variable does include C:\Program Files\Git\bin\ in order to know about bash.exe
Try and launch, for testing, VSCode after setting the PATH in a CMD with:
set GH=C:\path\to\git
set PATH=%GH%\bin;%GH%\usr\bin;%GH%\mingw64\bin;%GH%\mingw64\libexec\git-core;%PATH%
rem Then, in the same CMD
"%LOCALAPPDATA%\Programs\Microsoft VS Code\bin\code.cmd"

Related

Why does run fail after I compile a GoLang project to Web Assembly?

I created a Go(lang) project in Visual Studio Code. I created a main.go file that I will compile to WebAssembly, and another main.go that I will run as a server (to serve my Web Assembly glue file).
For reference, I'm following the tutorial here: https://golangbot.com/webassembly-using-go/
In a Visual Studio Code terminal, I do the following:
[cd to my wasm source folder with the first main.go]
${env:GOOS} = "js"
${env:GOARCH} = "wasm"
go build -o ../../assets/json.wasm
[cd to my server folder with the other main.go]
go run main.go
[I get the following error]
exec: "C:\Users\...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
I was able to run this server prior to the build. What's going on?
This should have just run. But now I'm not able to run the server. I get that strange "file does not exist" error.
I spent a lot of time trying to figure this out and finally got it! Here's the deal:
Either or both of the GOOS and GOARCH environment variables that are required by the build go command (for webassembly) seem to conflict with the go run command. I don't know why. I discovered this in a backwards kind of way.
(TLDR: use different terminals to build and run and don't set these environment variables globally -- set them prior to every build. Use the Terminal>Split Terminal to maintain the build settings between tests! ).
Using the Visual Studio Code Powershell terminal, I set these 2 variables (or so I thought) and then ran the build. Then I ran the server to try to see the fruits of my labor and got a strange error in the Chrome console (something about expecting one magic word but receiving another). It turns out this error is fairly generic and after some googling, determined it probably meant something happened with my build. After trying a few more times unsuccessfully to build, I decided to set the environment variables in windows (as SYSTEM variables) so that I didn't have to keep setting them when I did my build.
I built again (still no build errors), but then when I went to run the server, I got the
exec: "C:\Users...\AppData\Local\Temp\go-build3258126417\b001\exe\main": file does not exist
error. At this point, I couldn't run any of my Go servers in any project. Since the only "global" thing I'd done was set those 2 environment variables, I decided to remove them. I could now run my Go servers. But I still couldn't execute my builds in the browser. What's going on??
I figured that since setting the global environment variables had an effect (albeit, a negative effect) whereas I hadn't experienced that issue when manually setting them directly in the terminal prior to each build, then maybe there was something wrong with the way I was setting the variables (I don't use Powershell very often).
After more googling and some experimentation, I discovered the "correct" way to set these variables in the terminal (noted in my original question). So manually setting them (the right way) prior to the build fixed the build issue (it wasn't building correctly since those variables weren't being set properly).
Now I knew the variable were getting set properly because now I was getting that error when I set them manually prior to the build. So now what?
I killed the terminal after build, and then started a new terminal, and the run was successful.
So bottom line: the GOOS and GOARCH environment variables should not be set when running a server, so don't start a server in the same terminal that you used to build the web assembly code!

Problem trying to run Flutter on any IDE on macOS

I recently got the idea to try out flutter and found particularly difficult to implement it on my macOS (intel).
I have well updated my path, I could run flutter doctor nicely.
Flutter doctor -v
The problem resides in setting up the IDE, I tried both VScode and IntelliJ IDEA.
And I got the same result both time.
env: bash issue
When trying to create a project, there is no issue recognizing the path as shown on this picture
, the problem is brought up right after, when I click Create. It says that env: bash no such file or directory. What I don't understand is that I have a Zsh Shell, and I changed the setting on my IDE to use the /bin/zsh
But I still get a bash (my old SHELL) problem ?
I get the same problem on VScode.
If anyone has any help or information to provide, I would gladly accept it !
Thanks a lot.

Perl calls using system abruptly start failing

This week one of my standard perl [Strawberry perl 5, version 32, subversion 1 (v5.32.1) built for MSWin32-x64-multi-thread] scripts started failing. I tracked it down to a failing backtick operation.
Investigation showed that all the system-type calls, backtick, qx, pipe open, are failing. I tried building a debug version of perl, and even that fails, as the build process uses miniperl, which has the same problem.
..\miniperl.exe -I..\lib ..\make_ext.pl "MAKE=nmake -nologo" --dir=..\cpan --dir=..\dist --dir=..\ext --nonxs
Can't spawn "cmd.exe": No such file or directory at ..\make_ext.pl line 580.
Can't spawn "cmd.exe": No such file or directory at ..\make_ext.pl line 582.
Unsuccessful make(dist/if): code=65280 at ..\make_ext.pl line 584.
I tried defining PERL5SHELL (full path to cmd, pwsh in place of cmd), turning off malware protection, everything I could think of reverting.
So, the actual question:
Does anyone have a suggestion for how I can track this down? It was working on Thursday, and there have been no system updates since then [OS version 10.0.22000].
I ran into the same problem starting a couple of weeks ago. I use ActiveState perl, so I tried installing Strawberry perl, but got the same problem w/ Strawberry. I also saw the zero length files getting created. This is happening on multiple machines. One is Winver 1909 and the other is 21H2.
A workaround is to use the full path for the program you want to run.
You can also insert the full path to cmd.exe ahead of the program. Try this:
$temp = `$ENV{COMSPEC} /c date /T`;
print "\$temp = $temp";
I've been assuming this was due to a W10 security update, but I really do not know the cause. I am going to write a sub called Backticks() that I could use like this:
print Backticks('date /T');
sub Backticks would return $ENV{COMSPEC} /c #_.
This is a hack, but at this point I do not know what else to do.
Using the Malwarebytes beta (4.5.10.200) version fixes this problem for me.
I ran into the same problem starting about 10 days ago. I thought it had to do with path, but it appears ok. Problem is on 2 machines: Win10 and Win11. The Win11 PC I just purchased a couple of days ago, install strawberry and tested. Same error when I call system(..).
Short term solution I found is to copy cmd.exe from c:\windows\system32 into the directory where the script is running. Not a good solution, but it gets me through the day. I suspect it's some security update made in windows in the past couple of weeks.
Update 6/15/22: I can confirm that Malwarebytes beta (4.5.10.200) version fixes this. However, I had this problem on my Win11 PC before installing Malwarebytes. Maybe it's a problem with Windows Security?

Anaconda activate environment command is not working after windows update

I am getting this error -> \Gow\bin was unexpected at this time whenever I open my anaconda prompt and also the same error if I try to activate a particular environment. It all started after my recent windows update. I know this a path related problem, I have fixed few after my windows update but this error doesn't make any sense to me. May be there is some quotation related problem, I looked for them in the environment variable path but I couldn't find any such error. Any Idea how can I fix this error?
Thank you so much in advance.

Sencha Touch Cmd tool 3.0 install not working on Mac

-bash: sencha: command not found
I just spent a few hours trying to make this Sencha Cmd works on my MacBook, but just couldn't. I uninstalled a previous version and just couldn't get it to work again. I always get the
-bash: sencha: command not found
error. I did try everything in this post, without success.... I even get an error when I call
.bash_profile
stating that it's not found... Do you have any idea what could be the problem ?
I'm fairly new to the Linux command world so I might miss a point here. Maybe I might use "sudo" to be granted acces to bask_profile ?
EDIT : I got it working for the current bash session. I position myself at the user root (~/) and call ". .bash_profile"(the space is important here). BUT... it only works for the current session. As soon as I close Terminal and reopen it, I loose everything :-(
OK, just so you know, I managed to fix the damn thing be opening and editing the ".bash_profile" file in a text editor (TextMate for me). This is an hidden file, but you can configure your Mac to show those files in Finder. The file is located at your user's root. It is quite annoying to have to spend hour messing in path and environment variables in 2013... Installer should do those things and reports error if something happens in the install process.

Resources