pub global activate command - $HOME/.pub-cache/bin not on path
Asked Answered
C

12

36

I was trying to install dart2 recently, but when I try to install pub global activate stagehand, it comes with a warning.

Warning: Pub installs executables into $HOME/.pub-cache/bin, which is not on your path.

You can fix that by adding this to your shell's config file (.bashrc, .bash_profile, etc.):

export PATH="$PATH":"$HOME/.pub-cache/bin"

so i went to my .bash_profile file and added the above, and the file looks like this:

export PATH=/users/kevinau/dart/flutter/bin:$PATH
export PATH="$PATH":"$HOME/.pub-cache/bin"

but then I run webdev and the command is still not found.

can anyone walk me thru how to fix this?

I tried echo $PATH and return the below:

/users/myspace/dart/flutter/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/sbin/.pub-cache/bin

but how do I fix it?

Catboat answered 13/10, 2018 at 15:0 Comment(1)
add export PATH="$PATH":"$HOME/.pub-cache/bin" in your terminal and execute your android studio termnial too. and restart the terminal.Foghorn
V
77

I have just run the following command in my cmd

export PATH="$PATH":"$HOME/.pub-cache/bin"

then I again run the command dart pub global activate fvm and the error is gone. In my case, I am having the error during installing fvm package.

Vegetation answered 6/5, 2021 at 9:47 Comment(2)
run on terminal not worked. but run in vscode terminal is worked.Deflection
This is an easy solution on Mac. ThanksMillstream
T
12

Edit zshrc file using vim on terminal

vim ~/.zshrc

or

vim ~/.bashrc

edit data on zshrc after pressing "i" on keyboard. Export flutter location, aqueduct location and dart sdk location

export PATH="$PATH":"$HOME/Development/flutter/bin"
export PATH="$PATH":"$HOME/Development/flutter/.pub-cache/bin"
export PATH="$PATH":"$HOME/Development/flutter/bin/cache/dart-sdk/bin"

After editing press "esc" key ~:wq for saving Check working of aqueduct using

aqueduct --version

or

aqueduct serve
Thad answered 29/6, 2020 at 17:19 Comment(0)
B
5

Add dart-sdk path to .bash_profile

export PATH="$PATH:`pwd`/flutter/bin"
export PATH="$PATH:`pwd`/bin/cache/dart-sdk/bin"
export PATH="$PATH:`pwd`/.pub-cache/bin"
Biconvex answered 13/6, 2019 at 10:40 Comment(0)
L
5

If you’re a mac user Just do the following: In any system folder, you can go to home directory via command+shift+h In home directory, you need to edit .bashrc file, but it’s hidden, use command+Shift+. To unhide. Now, you can edit file and add this code to finish line:

export PATH="$PATH":"$HOME/.pub-cache/bin"

Congratulations your problem has been solved 😊

Levine answered 19/3, 2022 at 0:33 Comment(2)
on my system, the file in home directory i needed to edit was .zshrc thnak you @Mohammad Hassan Farhadi for the directions on how to find it :)Jennelljenner
I continued to have problems and after editing .zshrc I had to do a re-auth for my login see solution here: #57941789Scrunch
N
3

For Unix-based system:

echo 'export PATH=$PATH:$HOME/.pub-cache/bin' >> ~/.bashrc
source ~/.bashrc
Nazareth answered 20/11, 2022 at 19:12 Comment(1)
Use this after getting melos 'missing HOME path' ( for macOS users too)Woodpile
T
2

For Windows

Add C:\flutter\.pub-cache\bin into your system variable path

Thrilling answered 8/7, 2021 at 18:19 Comment(1)
There is no bin folder located thereHoover
A
1

System Properties -> Environment variable -> System variable -> Path -> New -> $HOME/.pub-cache/bin

Ablepsia answered 31/3, 2020 at 3:55 Comment(0)
S
1

I was setting my global environment variables after that warning on Window 10 pc but it was still giving me warning that your variable is not set even after I set all variables in environment variable settings

So I Simply restart my windows , it took some time for updating then after my pc starts. I ran this command "dart pub global activate protoc_plugin" and boom waning was gone

Sometimes windows do not get variables when they are set in present boot state so reloading boot (restarting windows) resolves the error

Society answered 12/3, 2022 at 20:18 Comment(0)
M
0

For webdev you need also

pub global activate webdev
Mckean answered 13/10, 2018 at 15:23 Comment(8)
yes that too, both stagehand and webbed are both currently command not foundCatboat
Do you have the Dart SDK installed? You can't use the Dart SDK included in Flutter for web development.Wheeler
"and the command is still not found." is also not very helpful. Please add the full and exact error message to your question.Wheeler
yes I have the Dart SDK installed, but how I do I differentiate Flutter's Dart SDK and Dart for Web SDK?.Catboat
When I type command webdev, it returns -bash: webdev: command not foundCatboat
Is there a file webdev in $HOME/.pub-cache/bin? Did pub global activate webdev succeed or did it cause an error?Wheeler
yes there are both webdev and stagehand in $HOME/.pub-cache/binCatboat
looks like there is something wrong with $HOME. Your path .../sbin:/sbin/.pub-cache/bin should be /sbin:/users/kevinau/.pub-cache/bin. Also your path starts with /users/myspace/dart/flutter/bin: and as mentioned the flutter SDK doesn't work with web programming. Also in path you have /users/myspace, but in the command in your question you use /users/kevinau/.Wheeler
V
0

after install flutterfire global, my path in windows 10 will be :

C:\Users\Windows\AppData\Local\Pub\Cache\bin
Visit answered 13/1, 2022 at 8:44 Comment(0)
T
0

Its works for me...

export PATH="$PATH":"$HOME/.pub-cache/bin"
Tunnage answered 31/8, 2022 at 6:25 Comment(0)
D
0

Use this for windows to find the path. Paste this in file explorer %LOCALAPPDATA%\Pub\Cache\bin

Dogleg answered 12/2 at 9:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.