Kevin
Kevin

Reputation: 547

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

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?

Upvotes: 40

Views: 65038

Answers (12)

Duc Nguyen
Duc Nguyen

Reputation: 588

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

Upvotes: 1

sanevys
sanevys

Reputation: 559

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

Upvotes: 0

ahmnouira
ahmnouira

Reputation: 3391

For Unix-based system:

echo 'export PATH=$PATH:$HOME/.pub-cache/bin' >> ~/.bashrc
source ~/.bashrc

Upvotes: 8

DevFlutter X
DevFlutter X

Reputation: 39

Its works for me...

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

Upvotes: 0

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 😊

Upvotes: 6

Muzammil Hassan
Muzammil Hassan

Reputation: 486

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

Upvotes: 1

freddi andrew
freddi andrew

Reputation: 45

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

C:\Users\Windows\AppData\Local\Pub\Cache\bin

Upvotes: 0

Rishi Malgwa
Rishi Malgwa

Reputation: 389

For Windows

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

Upvotes: 2

MRazaImtiaz
MRazaImtiaz

Reputation: 2157

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.

Upvotes: 83

rencheeraj
rencheeraj

Reputation: 411

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

Upvotes: 12

Zhuo Zhou
Zhuo Zhou

Reputation: 51

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"

Upvotes: 5

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657008

For webdev you need also

pub global activate webdev

Upvotes: 0

Related Questions