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

Kevin picture Kevin · Oct 13, 2018 · Viewed 9.2k times · Source

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?

Answer

Zhuo Zhou picture Zhuo Zhou · Jun 13, 2019

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"