33

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?

Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
Kevin
  • 477
  • 1
  • 5
  • 13
  • 2
    add export PATH="$PATH":"$HOME/.pub-cache/bin" in your terminal and execute your android studio termnial too. and restart the terminal. – Prabudda Fernando Mar 09 '22 at 01:37

11 Answers11

67

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.

MRazaImtiaz
  • 1,964
  • 1
  • 13
  • 23
11

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
rencheeraj
  • 391
  • 3
  • 4
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"
Zhuo Zhou
  • 51
  • 1
  • 4
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

  • 1
    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 :) – tmr Aug 16 '22 at 17:41
  • I continued to have problems and after editing .zshrc I had to do a re-auth for my login see solution here: https://stackoverflow.com/questions/57941289/how-do-i-solve-error-failed-to-list-firebase-projects-see-firebase-debug-log – Chris Bennett Apr 04 '23 at 19:19
2

For Windows

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

Rishi Malgwa
  • 339
  • 1
  • 11
2

For Unix-based system:

echo 'export PATH=$PATH:$HOME/.pub-cache/bin' >> ~/.bashrc
source ~/.bashrc
ahmnouira
  • 1,607
  • 13
  • 8
1

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

Duc Nguyen
  • 530
  • 8
  • 16
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

Muzammil Hassan
  • 336
  • 2
  • 10
0

For webdev you need also

pub global activate webdev
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • yes that too, both stagehand and webbed are both currently command not found – Kevin Oct 13 '18 at 15:31
  • 1
    Do you have the Dart SDK installed? You can't use the Dart SDK included in Flutter for web development. – Günter Zöchbauer Oct 13 '18 at 15:34
  • "and the command is still not found." is also not very helpful. Please add the full and exact error message to your question. – Günter Zöchbauer Oct 13 '18 at 15:35
  • yes I have the Dart SDK installed, but how I do I differentiate Flutter's Dart SDK and Dart for Web SDK?. – Kevin Oct 13 '18 at 15:49
  • When I type command webdev, it returns -bash: webdev: command not found – Kevin Oct 13 '18 at 15:49
  • Is there a file `webdev` in `$HOME/.pub-cache/bin`? Did `pub global activate webdev` succeed or did it cause an error? – Günter Zöchbauer Oct 13 '18 at 15:54
  • yes there are both webdev and stagehand in $HOME/.pub-cache/bin – Kevin Oct 13 '18 at 16:08
  • 2
    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/`. – Günter Zöchbauer Oct 13 '18 at 16:17
0

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

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

Its works for me...

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