command 'go.tools.install' not found - windows

I am trying to install Go tools in my VS Code editor and when I select the View, CMD, Install and select Go: Install/Update tools, I get this -> "command 'go.tools.install' not found"
What am I doing wrong?

As seen in Microsoft/vscode-go issue 755:
For all guys who are stuck with command 'go.tools.install' not found problem on Windows.
Check if %GOPATH%\bin is in your PATH environment variable.
After half and an hour I finally figured out that PATH remains unchanged if you try to change it like set PATH=%PATH%.... You need explicitly change it in your system settings.
With recent Go installation, make sure GOROOT reference your Go installation folder.
I also like to set go.goroot to that folder in the settings of VSCode.
You don't need GOPATH: it defaults to %USERPROFILE%\go: make sure %USERPROFILE%\go\bin is in your PATH, before launching VSCode.
unzip go1.13.6.windows-amd64.zip anywhere (not in %USERPROFILE%\go, since it is reserved for GOPATH)
set GOROOT to C:\path\to\go (where you just uncompressed the Go archive)
add %GOROOT%\bin to %PATH%

In my case I was on Ubuntu and installed go using snap so I did the following:
Uninstall go from snap
sudo snap remove go
Download go from the original source: https://go.dev/doc/install
Install go as recommended in the source e.g.:
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz
Run the following to add the environment variables in the .bashrc:
echo export GOROOT=/usr/local/go >> ~/.bashrc
echo export GOPATH=\$HOME/go >> ~/.bashrc
echo export PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin >> ~/.bashrc
Note: Setting $GOROOT variable is obsolete in recent versions as discussed here
Restart the VS Code to read the environment variables set above
In VSCode press Ctrl+Shift+P and run again the GO: Install/Update tools, install everything selecting the checkboxes and you are good to GO!

In my case Go language was not installed so this command was not working from VS Code. Consider downloading and installing latest version of go language from https://go.dev/dl/
After I installed version 1.19.3 of go to my Windows 11 x64, the "go: install/Update Tools" command worked fine without any changes needed to be done to eviroment variables (PATH,GOROOT).(all changes were done by installer)
BTW restart of VSCODE really helps to make it work after installation of go.

Related

Unable to install Go packages in Macbook with M1 chip

When I ran the command "go install github.com/go-delve/delve/cmd/dlv" in the delve folder, after downloading go-delve in my go path, the terminal showed the following result:
"go install github.com/go-delve/delve/cmd/dlv: mkdir /Desktop: read-only file system"
Terminal result put here
When I googled the same, I came across a website(https://www.dev2qa.com/how-to-fix-read-only-file-system-error-when-run-mkdir-command-on-macos/) which requires me to disable System Integrity Protection on my MacBook and it asks me to hold the option key or command + R immediately after Mac chimes in reboot after starting the MacBook, until I see a boot in a "console/terminal" mode.. But nothing happened when I tried doing that.
I am not knowing what to do. Please guide me through the right way to install dlv and other packages of go successfully on my Macbook.
make sure you use the right go version (1.16 or later, arm64)
$ go version
go version go1.17.1 darwin/arm64
make sure the env is right by this command
$ go env
check GOROOT GOPATH GOARCH GOBIN
try to install it directly
$ go install github.com/go-delve/delve/cmd/dlv#latest
your error occurs because you have no permission of /Desktop, and i'm sure install dlv don't need something like this, it will install to ~/go/bin

How to get the sh formatter up and running?

The goal is to set up formatting for bash scripts (.sh files). So I'm trying to play around with the .sh formatter. From the project's github quick start section; I have go installed and have pulled in the shfmt module like so: GO111MODULE=on go get mvdan.cc/sh/v3/cmd/shfmt. But on trying to invoke the shfmt command. I'm getting the common command not found error. How do I actually use the shfmt command. My assumption is this is plug and play i.e. I don't need to actually go and fiddle around with PATHs or ENVs.
The command is installed as $HOME/go/bin/shfmt (unless GOBIN is set, then it's $GOBIN/shfmt):
$ go help install
usage: go install [-i] [build flags] [packages]
Install compiles and installs the packages named by the import paths.
Executables are installed in the directory named by the GOBIN environment
variable, which defaults to $GOPATH/bin or $HOME/go/bin if the GOPATH
environment variable is not set.
The installation happens with a help of go install command as Peter mentioned. I would like to make a step by step that worked for me on Windows 7 machine, because I bet there are some of you who don't know anything about go language and don't even want to hear about it:
Install go language from golang.org (I used installer for Windows of course)
Download .sh formatter and unzip it somewhere
Navigate to the root directory ..\sh-master with your favourite terminal (I use GitBash or you can use cmd.exe which every Windows has by default)
Run command go install and installation should start
Once installation is done, through terminal (GitBash or cmd) navigate to $HOME/go/bin (on Windows by default it's under C:\Users\your_username\go\bin)
From here you can use the shfmt command like so shfmt -l -w yourBashScript.sh
Voila! now your bash script yourBashScript.sh is modified and formatted)

Cannot Install Delve Go Debugger on Mac

I am trying to follow along with the following YouTube video on getting started with Go Debugging.
It recommends following the Delve installation instructions on the official Delve github repo. For Mac users, they are as follows:
Making sure the toolchain is in place
xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
Using "go get" to install Delve
go get -u github.com/go-delve/delve/cmd/dlv
Making sure developer mode is enabled in Xcode
sudo /usr/sbin/DevToolsSecurity -enable
Developer mode is already enabled.
To check that the installation has been completed correctly, I tried running the following in my Go project directlry:
dlv debug
zsh: command not found: dlv
The author of the video tutorial recommends updating GOPATH and PATH variables in the ~/.bash_profile file in the case that the command is not recognized. I did so so by adding:
export GOPATH=/Users/<user_name>/go/src/
export PATH=$PATH:/Users/<user_name/go/src/my_project
However, even after doing so, I get the same result when trying to run the debugger:
dlv debug
zsh: command not found: dlv
Even if I change the shell for the default zsh to bash, using exec bash, I get the same result.
In order to run an executable, it needs to be available in your PATH.
1. Configure your path.
Make sure that your GOPATH and $GOPATH/bin directories are set correctly in your shell environment. You can do this by adding the following lines to your shell configuration.
~/.zshrc if you're using zsh.
~/.bash_profile if you're using bash.
export GOPATH="$HOME/go"
export PATH="$GOPATH/bin:$PATH"
2. Re-load your shell configuration.
Make sure to either restart your shell or run source on your shell configuration file after the changes:
source ~/.zshrc if you're using zsh.
source ~/.bash_profile if you're using bash.
3. Install the dlv package.
go install github.com/go-delve/delve/cmd/dlv
This is assuming that you're using /Users/<username>/go as your GOPATH.
You should now be able to run dlv from your terminal session.
Good luck!
Set the environment variable GOBIN to be where you want the dlv binary to be installed.
For example:
GOBIN=~/bin go install github.com/go-delve/delve/cmd/dlv
This will install dlv in ~/bin
Clarification
When you run go install, the installation path can be specified by setting the GOBIN environment variable.
There are two ways to set the environment variable:
1) Run export GOBIN=<SOMETHING> before you run go install ..
$ export GOBIN="$HOME/bin"
$ go install github.com/go-delve/delve/cmd/dlv
The export command will alter the environment in the current terminal session. Any later command you execute will see the value you set for GOBIN
When you go with this approach, you usually want to have this environment variable active not only in this session, but all future sessions as well. So it's better to add the line to your bash profile.
2) Set the environment variable only for the command.
$ A=10 some-command
In this case, some-command will see the value of the environment variable A set to '10'. If you run a later command, it will not see this value.
This approach is useful when you are just trying things out, or if you only want to set certain environment variables in certain situations.
The command line I provided as the answer follows this second approach.
It sets the GOBIN variable to the ~/bin directory, and then invokes go install in the same line. This way, this invocation of go install will install dlv in ~/bin
This of course assumes you have a bin directory in your home directory.
If you don't have such directory, then this will not work.
The idea is not to copy paste the line as is. The idea is to change ~/bin to be the directory where you would like the dlv binary to be installed.

How to compile GCC on macOS Catalina? [duplicate]

I previously had Conda running smoothly on Mojave, but I've found that the upgrade to Catalina moves the "anaconda3" folder to your Desktop > Relocated Items > Security > anaconda3. It seems Catalina's security settings may not allow applications to install directly under the user directory anymore.
I tried the suggestion here, written below:
Hi, I might have a solution
Copy the folder anaconda3 located in Relocated Items to /Users/myname/
Open Terminal
Enter: export PATH=''/Users/myname/anaconda3/bin:$PATH"
Enter: conda init zsh
It worked! Good luck!
But this doesn't work for me. After conda init zsh I get:
-bash: /Users/USER/anaconda3/bin/conda: /anaconda3/bin/python: bad interpreter: No such file or directory
How can I get Conda up and running again without losing all my virtual environments? Thanks!
Update
I got Conda to work following #Ted Shaowang's suggestion. This means that conda env list shows all the virtual environments created via Conda.
However I am still experiencing an issue with virtualenv as since I changed the default anaconda3 file locations, python cannot be found.
The python executable located at .virtualenvs/env/bin/python cannot be found. Do I need to make further changes in order for python to work from virtualenv too?
I have the exact same problem and this works for me:
After you move anaconda from "Relocated Items" to ~/anaconda3, edit the first line of ~/anaconda3/bin/conda file from #!/anaconda3/bin/python to #!/Users/USERNAME/anaconda3/bin/python to reflect the change.
I would probably abstain from using the above solution. That ~/anaconda3/bin directory has lots of runnables (not just the conda one) that would need to be altered in this manual way. For example, unless you make the same change you cannot run jupyter notebook either, neither from base nor from other envs you might have.
My tip: Try getting a requirements file for your virtual envs, and do a fresh installation. You could use pipreqs to get the requirements used for individual projects: https://www.idiotinside.com/2015/05/10/python-auto-generate-requirements-txt/
No solution will be completely working without fixing the baked-in hard-coded prefix entries in files. There's a longer description and a recommended fix at https://www.anaconda.com/how-to-restore-anaconda-after-macos-catalina-update/
Technically this is reinstalling anaconda, however, I restored all my conda envs so, hopefully this is an acceptable solution!
Here is how I got it working on Catalina as of a few minutes ago (now using z-shell):
- Verified the existence of "Relocated Items" directory on my desktop and the "anaconda3" directory and its contents inside
- Navigated into the envs directory under "anaconda3" and left the finder window open (see screenshot)
THEN:
opened new Terminal (z-shell)
ran (this installed to /usr/local/anaconda3):
brew cask install anaconda
after installation was successful I opened my ~/.zshrc file (for my z-shell aliases) and added the following line:
export PATH="/usr/local/anaconda3/bin:$PATH"
saved my ~/.zshrc file, then reloaded with:
source ~/.zshrc
to verify conda command works now, I ran:
conda env list
for me, this showed a base env and that was it
then open Finder to the new envs location:
open /usr/local/anaconda3/envs/.
I dragged (moved) all my old envs into the new envs folder, and then ran:
conda env list
And all my old envs are back! :)
updated my PyCharm interpreter / env paths to reflect the new locations of these envs (had to restart PyCharm after, but now it works!)
DONE
Unsure whether this is considered a comment or at least a temporary answer, but I would refrain from attempting to fix any Catalina compatibility issues with Anaconda for now. See this GitHub issue.
I have the same problem, and this work for me :
My solution:
Copy your anaconda3 from Relocated Items folder
Paste in User/YourUserName
Open conda file in anaconda3/bin with the editor and edit the first line #!/anaconda3/bin/python to #!/Users/YourUserName/anaconda3/bin/python
Save it and run conda file
Open Terminal
Run this : export PATH=''/Users/YourUserName/anaconda3/bin:$PATH"
Run conda init zsh
I had incurred the same issue, and the following solution worked for me, and this is the easiest solution:
Instead of messing around copying the anaconda3 file from relocated items into User/USERNAME directory, better would be just to reinstall anaconda navigator's latest version from its official website : https://www.anaconda.com/distribution/#macos
While installation, it will ask you some permissions which are a result of new Apple Security Policies, just grant them, and it works just the way it should after this fresh installation!
This is what worked for me.
These are my header files (Catalina 10.15):
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
Run sudo find /Library -name stdio.h to see where yours are located.
Mojave 10.14 header files:
$ sudo find /Library -name stdio.h
/Library/Developer/CommandLineTools/usr/include/c++/v1/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/sys/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/stdio.h
As can be seen the SDKs are now split into MACOSX10.14 and 10.15 unlike in Mojave.
TLDR
So, these were my SDK folders on Catalina:
Rename MacOSX.sdk to MacOSX_orig.sdk
Right click on MacOSX10.14.sdk
Duplicate
Rename duplicate folder to MacOSX.sdk
Your folder structure should now look like this:
Like this we are basically using the previous version's OSX sdk as sysroot. Hope this helps.

firebase-tools "-bash: firebase: command not found"

Excited that Firebase's hosting is now out of beta. Trying to get going with with the firebase-tools package and I've successfully installed it:
npm install -g firebase-tools
Trying to run any tool fails with
-bash: firebase: command not found
I've tried putting the following command in my .bash_profile without any luck
export PATH=/usr/local/share/npm/bin:$PATH
Any ideas? Pretty new to the command line in general.
Thanks!
Run code below with terminal,
alias firebase="`npm config get prefix`/bin/firebase"
Installing firebase-tools globally did the trick for me :
npm install -g firebase-tools
You should add the npm bin folder to your bash PATH variable. To do that, run:
npm get prefix
And it should output something like /home/your-username/npm-global or /home/your-username/npm-packages.
Then in your ~/.bashrc or ~/.bash_profile (if you're in a Mac) file, add:
export PATH="/home/your-username/npm-global/bin:$PATH" # Add npm bin PATH
Note the "/bin" after the npm get prefix result.
#mklement0 That answer looks good, but I'm worried it will be intimidating to someone who is so new to the command line. So I'm going to cherry-pick the most relevant piece of it.
#cienki Run this command to see what you should be putting in that PATH prefix in your .bash_profile file:
npm get prefix
by chance if you are using macOS with m1 chip
arch -x86_64 npm i -g firebase-tools
assuming that you haven't set the PATH
export PATH="`npm config get prefix`/bin:$PATH"
That's all and enjoy
On macOS: Use
curl -sL firebase.tools | upgrade=true bash
It worked for me
firebase -V
Using Windows 10, Bash
This worked for me:
npm get prefix // to find Path which for me it was C:\Users\User\AppData\Roaming\npm
search "Environment Variables" which located in "System Properties".
Under "System Variables", find the PATH variable, select it, and click "Edit". Click "New" and add the path found with the "npm get prefix" command earlier (which was for me C:\Users\User\AppData\Roaming\npm)
Then click "Ok"
Restart Bash
firebase --version //to check firebase version
Bruno's answer did the trick, I only needed to add a dot at npm-global in Ubuntu in .bashrc:
export PATH="/home/your-username/.npm-global/bin:$PATH" # Add npm bin PATH
Below command works for me on terminal
curl -sL firebase.tools | upgrade=true bash
This command install firebase tool for me
After installing:
$ npm install -g firebase-tools
$ firebase init
-bash: firebase: command not found
"If you are getting the above output then follow the below steps:"
For Windows Users:
type this cmd :
$ npm get prefix
C:\Users\Jeet\AppData\Roaming\npm [this is the location]
Now you have to set in enviorenment variable -> (windows+r) -> sysdm.cpl -> Advanced(tab) -> Environment Variables
-> under the System Variables -> click on path -> edit -> C:\Users\Jeet\AppData\Roaming\npm [paste] the above location -> apply - ok - ok.
Restart your bash terminal
Thanks!!!
For Mac OS Sierra:
$ sudo npm install -g firebase-tools
To stop other Node process use $ ps aux | grep node
If needed to upgrade or install emulator - $ npm install -g #google-cloud/functions-emulator
Ready to go $ firebase --version
For anyone using MacOS Catalina 10.15.2 getting the bash PATH variable fixed the issue for me.
Run:
npm get prefix
Then run:
export PATH=/Users/userid/.npm-global/bin:$PATH
Note: I recently upgraded from my old High Sierra MacBook Pro, and was confused as well.
For anyone using nvm the error could arise because you are on a different nvm version than you were on when you first installed firebase tools globally. That's what it was for me. When I restarted webstorm nvm switched to a different version.
Run nvm list to check the version you are on and run nvm use x.x.x to switch to the right version where you installed firebase tools originally.
This worked for me on Mac (same thing the others have been posting above, just for Mac):
go to your home folder in Finder (named after your user name, in my case "macbook")
press cmd+shift+dot (will reveal hidden files)
go the .npm-global/bin folder and copy its path (Finder menu -> View -> Show Path Bar, right click on the bin folder in the path bar -> "Copy 'bin' as Pathname")
open Terminal (by default the home folder) and go nano ~/.bash_profile
at the top of the file add export PATH="<cmd+v>:$PATH" (will look similar to this: export PATH="/Users/macbook/.npm-global/bin:$PATH")
save .bash_profile changes and restart Terminal, firebase command should work now
if you installing firebase-tools using
yarn global add firebase-tools
i got same error then i got answer and execute this
export PATH="$(yarn global bin):$PATH"
and then i can do firebase login pretty well
I am on Linux and installing the package with admin privileges resolved the problem:
sudo npm i -g firebase-tools
Simply reinstall node.js. This worked for me and fire command was recognized.
You forgot sudo type this
sudo npm install -g firebase-tools
problem solved.
I know most answers work for all generic 'command not found' errors. Basically by manually setting PATH variable but there's an easier way for this specific problem relating 'firebase command not found':
Try this cURL command and it will fix this issue for good and will minimise any user errors.
Install the Firebase CLI using the automatic install script
Run the following cURL command (Mac or Windows):
curl -sL https://firebase.tools | bash
Source: https://firebase.google.com/docs/cli#install-cli-windows, https://firebase.google.com/docs/cli#install-cli-mac-linux
This is for updated mac mac Os Catalina(10.15.1+) & on zsh.
Go to Terminal (vim .zprofile)
add this export PATH="/Users/Your Username/.npm-global/bin:$PATH"
Works for me!
Faced the same issue, am a newbie backend guy.
Used npm install firebase-tools
It doesn't install and you can't run.
I tried looking at the forums and here's what worked for me:
sudo npm install -g firebase-tools.
Then it asks for Permissions when you firebase login.
Am using Ubuntu.
After trying pretty much everything, only one worked for me (I'm on MacOs Catalina):
Try the following in your terminal:
curl -sL https://firebase.tools | bash
This will check the OS of your machine and then install everything else automatically and properly.
The command is from the official Firebase Documentation.
https://stackoverflow.com/a/60474459/1245341
After installing
$ npm install -g firebase-tools
Note the directory where it istalled What I did was locate the directory where firebase was installed. In my case C:\usr\local then I copied the three firebase files. I also went into the node_modules folder and copied the firebase tools folder. Then I went to my app directory in file manager and pasted the firebase files, then created a new node_modules folder and pasted the firebase-tools folder.
Now go to your cmd and run
$ firebase init
It should work
I tried a lot of things from here and from other forums, but what ended up working for me (and this is more of a work-around) was to download the binary and then open it and it set up all the firebase stuff for me.
However, I found that if I moved it after opening it once, it did not work. So first move it to wherever you want to leave it and then run the .exe.
This allowed me to skip configuring the PATH variable which was nice.
I'm on a Windows 10 Pro Education. Hope this helps someone who has a similar struggle.
Adding to Durul Dalkanat's answer,
Assuming you have executed npm install firebase-tools -g
Firstly get the output of the command of npm get prefix.
Open .bashrc file which is in the home directory and add alias <output of npm get prefix>/bin/firebase at the end of the file.
Run source .bashrc in the home directory.
Enjoy!
The alias of firebase will be the actual firebase path in the main system and this solution should work flawlessly.
if you're windows 8 user, one possible solution is to put the PATH in environment variables manualy...
On the Windows desktop, right-click My Computer.
In the pop-up menu, click Properties.
In the System Properties window, click the Advanced tab, and then click Environment Variables.
In the System Variables window, highlight Path, and click Edit.
In the Edit System Variables window, insert the cursor at the end of the Variable value field.
If the last character is not a semi-colon (;), add one.
After the final semi-colon, type the full path to the file you want to find.
For me it was: C:\Users\ 'username' \AppData\Roaming\npm
To get your path put this string in you command line:
$ npm get prefix
Click OK in each open window
I tried all the answers above, other SO answers, and GitHub answers but nothing worked. The only thing that worked for me was to save whatever was inside my index.js file temporarily somewhere else, delete the entire cloud functions folder, then reinstall and start everything from the very beginning.
After many hours trying everything the only thing what helped (on windows) was downloading and installing node again.
I found a solution.
npm i express firebase-tools
If you are admin on your PC, installing firebase and firebase-tools with -g flag should resolve the issue (the path will added to the global PATH variable) but if you are an admin, you may have to add that path yourself.
Seeking help from one of the top answer, issue this command will return the path where firebase is installed
npm config get prefix /bin/firebase
In my case the following is returned.
C:\Users\*user_name*\AppData\Roaming\npm
Copy that path (from first line) and visit this page on how to update path variable (Window + x then visit systems > Advance Settings). Here add a new entry in path and past that path there. Firebase command should work from command prompt every time without the use of alias required.

Resources