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?


Solution 1:

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.

Solution 2:

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