15

I am trying to install the flutter version manager to switch the flutter version among the different flutter projects. I use the command to install the fvm - pub global activate fvm

but when I run the command on the terminal - fvm help There is an error -bash: fvm: command not found

How to fix it ?

MANISH PATHAK
  • 2,602
  • 4
  • 27
  • 31

6 Answers6

23

Your .pub-cache binaries are not yet added to your PATH variable, used by your terminal. Add path with the following command:

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

This is the location where fvm is installed. So by exporting this path to your PATH variable you should be able to get fvm working from anywhere in your terminal.

Corentin Houdayer
  • 988
  • 2
  • 8
  • 19
vanlooverenkoen
  • 2,121
  • 26
  • 50
14

If you installed fvm using pub and you already have it in your path but you are still getting the error, follow these steps:

  1. run dart pub cache repair // You may get an error: Failed to precompile fvm:main:. Just ignore that for now.
  2. run dart pub global activate fvm
mskolnick
  • 1,062
  • 8
  • 12
7

you can do a

flutter clean

then when its done, run

dart pub global activate fvm

when it's done it should work now, close the current bash terminal and open a new one

IBRAHIM ALI MUSAH
  • 831
  • 10
  • 19
3

You must add the path to the fvm executable to the $PATH environment variable. After running "pub global activate fvm" you should have seen a warning with instructions on how to fix it. You can watch this: https://youtu.be/R6vKde1vIGQ That will get you up and running.

Sander Roest
  • 839
  • 6
  • 10
0

First confirm if fvm.bat is executing successfully, you should have the folder already in environment variable PATH(%USERPROFILE%\AppData\Local\Pub\Cache\bin). If it is then for fvm to run in bash, instead of fvm.bat, you need to create a shortcut, a file named fvm with no extension, the containing folder should also exist in PATH variable, the file contains location to fvm.bat and ends with a whitespace and S*.

farfly
  • 126
  • 6
-1

if use windows 10 or later add system properties -> Environment Variables -> Path -> %USERPROFILE%\AppData\Local\Pub\Cache\bin