zsh: command not found: pub - macos

I'm getting this error message when try to install aqueduct on macOS Catalina with this command.
pub global activate aqueduct
I managed to install it by putting flutter in front of it but now I cannot run aqueduct. I tried
aqueduct --version
I get an error again
zsh: command not found: aqueduct
Here is my .zshrc file (I've added last second line to try to fix it)
export PATH="$PATH:/Users/peter/development/tools/flutter/bin"
export PATH="$PATH":"$HOME/.pub-cache/bin"
I don't know what else to do...

Edit zshrc file using vim on terminal
vim ~/.zshrc
edit data on zshrc after pressing "i" on keyboard.
Export flutter location, aqueduct location and dart sdk location.
NOTE, to change the your_path to your flutter directory. i.e where flutter is installed.
export PATH="$PATH":"your_path/flutter/bin"
export PATH="$PATH":"your_path/flutter/.pub-cache/bin"
export PATH="$PATH":"your_path/flutter/bin/cache/dart-sdk/bin"
After editing press "esc" key and type :wq for saving
Check working of aqueduct using
aqueduct --version
or
aqueduct serve

If you have flutter installed, try flutter pub global activate aqueduct

I got this error zsh: command not found: pub
quick answer if you already have flutter installed
run
flutter pub get
because You can either download the Dart SDK directly (as described below) or download the Flutter SDK, which (as of Flutter 1.21) includes the full Dart SDK.
In my case I wanted to install dependencies in pubspec.yaml in my dart project, but got zsh: command not found: pub.
What is pub
The pub tool has commands for managing packages and for deploying packages and command-line apps.

Well, I don't know what is aqueduct, but this is a common way to solve such issues:
When you see $ zsh: command not found: aqueduct,
run $ which aqueduct - it shouldn't work.
If it works, then the shell does know about a binary named aqueduct.
Find out in which folder aquedict is located, and add the path to it in export PATH=..., like in you did in .zshrc file.
If you found aquedict binary, and it still fails to work, try adding it permissions to execute:
chmod +rwx aquedict
If you didn't found aquedict binary, read the docs again. :)
In your case it's https://aqueduct.io/docs/getting_started/ ,
and the first step is to install Dart: https://dart.dev/get-dart

Related

How to setup multiple flutter versions on mac?

I want to install both flutter v1.22.6 and v2.0.5 on my mac.
currently I have v1.22.6 set up on my mac and have path for it set aswell.
I want a setup where if I enter the command flutter doctor that corresponds to v1.22.6 and when I enter the command flutter2 doctor that corresponds to v2.0.5
I am new to the terminal can someone please help? as of now flutter doctor corresponds to v1.22.6 only. I tried setting a path for flutter2 but that shows as no command found
You need to create alias
Navigate to your home directory:
cd ~
Open up .bash_profile using vi:
vi .bash_profile
or
vim .bash_profile
Add an alias (press i):
alias flutter2="~/place_of_folder/flutter2/bin/flutter"
Save the file (press Escape, type :wq, and hit Enter)
Restart Terminal
FVM (Flutter Version Management)
Using the FVM (Flutter Version Management) would be an optimal solution.
Briefly, FVM is an open-source dependency management tool that helps with referencing a certain Flutter SDK version to be used for a certain project, i.e each project can use a different Flutter SDK version.
Installation
Run the following command:
dart pub global activate fvm
Or, using Homebrew:
brew tap leoafarias/fvm
brew install fvm
Usage
Installing the SKDs:
Basically, you install the latest stable Flutter version by running the following command:
fvm install stable
Or, you could specify the version, as:
fvm install [version_number]
For instance, if you want to have the latest version in addition to 3.0.0, you should run the first command and the second command (as fvm install 3.0.0).
Using SDK for a project:
In the terminal, change the directory to your project, and run the following command:
fvm use stable
stable could be replaced with a specified SDK version. At this point, each project will have its own Flutter SDK based on the used fvm use version number.
However, you could also use the same version for all of your projects by running the following command:
fvm global stable
"How to know which version that I'm using for a certain project?"
In the terminal, change the directory to your project, and run the following command:
fvm doctor
Or, since you are able to run the Flutter commands via the used fvm SDK, you could also run
fvm flutter --version
For more information, you could check the FVM documentaion.
Open Terminal & type: echo $SHELL to check what SHELL you're using,
If you use ZSHELL, not BASH, just 1 step to do this task (if BASH, please flow content of #Adelina in this topic):
Open Terminal and type: nano ~/.zshrc
For me, I'm using 2 versions 2.10.5 & 3.7.x, with ver 2.10.5, I don't need to add alias, default is flutter doctor. And with ver 3.7.x, I just add 1 alias "flutter3" like below:
export PATH="$PATH:/Users/macbookpro/development/flutter/bin"
export JAVA_HOME=$(/usr/libexec/java_home)
export PATH="$PATH:/Users/macbookpro/development/flutterV3/bin"
alias flutter3="/Users/macbookpro/development/flutterV3/bin/flutter"
After add 4 lines above with 2 versions Flutter that you have on Mac, press Ctrl + O, tap Enter to save file ZSHELL, and then press Ctrl + X to close file ZSHELL.
Return to Terminal current session, restart Terminal or restart Mac and type flutter3 doctor or flutter doctor to test

Flutter commands do not work in terminal on Mac OS after update

I am running on a Mac, I downloaded Flutter through Git and can confirm that the files are all there, I also successfully updated my path in my ~/.zshrc file. This was all working fine until I ran flutter upgrade, after which the flutter command stopped working. I confirmed this by running which flutter and the output was:
/Users/aamir/development/flutter/bin/flutter
which looks correct. However, running flutter in my terminal gives me back this error:
: command not foundpment/flutter/bin/internal/shared.sh: line 5:
Not sure what's the issue here
So I worked this out by manually downloading the flutter SDK then replace it into the original flutter folder. I think it's a problem with the flutter upgrade not being able to completely revert the changes it made after failing to upgrade from the command line.
For zsh:
For zsh (Apple M1):
1.Open Terminal
2.Run: nano ~/.zshrc
3.Add: export PATH=[PATH_TO_FLUTTER_GIT_DIRECTORY]/flutter/bin:$PATH
4.Run: source ~/.zshrc
5.restart terminal
6.Run: flutter doctor -v

macOS High Sierra - flutter command not found

On a macOS High Sierra, I have installed flutter via
git clone https://github.com/flutter/flutter.git
I have add the folder to the path
Configured the system to run all the applications
But I still have the error
flutter command not found
If I try to run it from flutter windows and not from command line, it works fine.
utente-pc:bin itmdev$ ls
cache dart.bat flutter.bat
dart flutter internal
utente-pc:bin itmdev$ flutter
-bash: flutter: command not found
To add entry to macOS PATH variable try this :-
Open Terminal
sudo nano /etc/paths
Paste your flutter path(e.g. /Users/user/Documents/Flutter/flutter/bin)
Save the file and restart the terminal.
I solved this problem by below steps:
Open terminal
Go to your flutter folder
Inside flutter folder run this command pwd
This command will provide you a path. Copy that path
Now run this command export PATH="$PATH:<YOUR COPIED PATH>/bin"
Now run flutter doctor.

Always -bash: gomobile: command not found

I have installed gomobile at
/Users/GaryChan/go/bin/gomobile
and my project is
/Users/GaryChan/go/src/abc.com/project
When I try to run building android SDK at
/Users/GaryChan/go/src/abc.com/project/sdk
and run :
export ANDROID_HOME=/Users/GaryChan/Library/Android/sdk/ndk-bundle/
gomobile bind -target=android abc.com/project/sdk
I go install go and go mobile but to no avail.
When I execute gomobile at My Mac Terminal, the cmd always prompt -bash: gomobile: command not found
Then I cannot export the SDK. What should I do ?
https://godoc.org/golang.org/x/mobile/cmd/gomobile
Updates :
Go Version is :
go version go1.11.1 darwin/amd64
Make sure /Users/GaryChan/go/bin/ is in your $PATH. If it's not, edit your bash profile to add it. Your profile is a file in your home directory named either .profile or .bash_profile. It should contain a line like this:
export PATH="${PATH}:/Users/GaryChan/go/bin/"
Make this change, then close your Terminal window and open a new one, and you should be able to type gomobile to launch it.

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