Flutter - Flutter Version Management (fvm) package not working in windows
Asked Answered
L

10

6

I just added the the fvm package to switch the flutter channel from stable to master without downloading sdk components every time when switching flutter channels.

I have followed the step written in readme.md for switching the channel.

I have set the following path in my environment variables.

D:\Program_Files\FlutterSDK\SDK\flutter\bin;
D:\Program_Files\FlutterSDK\SDK\dart-sdk\bin;
C:\Users\User\AppData\Roaming\Pub\Cache\bin;

Now, i have opened my first project in which i want to use "flutter SDK's master channel". But, whenever i try to use the command "fvm use master". It's not working.

It is giving me an error like, 'fvm' is not recognized as an internal or external command,

So, can anyone suggest a solution?

Thanks.

Lightish answered 4/5, 2020 at 12:11 Comment(5)
Hope you activated the package, using pub global activate fvmMilepost
Yes i did it already.Lightish
Here are the options I would try. 1. If you are in windows 10 you can try refreshenv. 2. If you are using android studio closing the terminal and restarting by invalidating and clearing the cache could help. 3. Also you can try running like pub global list to make sure it contains fvm.Milepost
Maybe silly but make sure C:\Users\User\AppData\Roaming\Pub\Cache\bin; user in this path refers to your username. :)Milepost
Yes did it as wellLightish
D
8

In my case fvm commands did not work on Windows even tho I checked everything. It gave missing fvm.exe file and other errors. If you also stuck there you can use this way. Only way I managed to get it work is to use longer commands like these:

 flutter pub global run fvm:main list

Seems like all fvm commands:

  config     Set configuration for FVM
  flutter    Proxies Flutter Commands
  install    Installs Flutter SDK Version
  list       Lists installed Flutter SDK Version
  releases   Lists Flutter SDK releases.
  remove     Removes Flutter SDK Version
  use        Which Flutter SDK Version you would like to use
  version    Prints the currently-installed version of FVM

Works like this, you just need to add the fvm command to the ending of this - flutter pub global run fvm:main. So add any of them like this form:

flutter pub global run fvm:main releases
flutter pub global run fvm:main install 2.2.0
flutter pub global run fvm:main use 2.2.0
Decompound answered 15/5, 2022 at 3:33 Comment(1)
Thanks for this. Only this one worked for me.Socioeconomic
R
4

Hi adding in your path:

%LOCALAPPDATA%\Pub\Cache\bin

More info:

https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path

Rhiamon answered 3/9, 2020 at 6:25 Comment(0)
A
4

try :

pub global run fvm:main

pub global run fvm:main use VERSION

Aerostatic answered 1/5, 2021 at 1:34 Comment(2)
Why fvm command not work in VSCode, but work in the terminal application?Philippeville
Vscode terminal has probably not refreshed. You do source ~/.bashrc or source ~/.zshrc to refreshConformist
S
3

In my case Error Message was

Usage Error: Flutter version null is not installed

To fix this:

  1. I have activated FVM by dart pub global activate fvm;
  2. Printed installed fvm list by fvm list, it should give result as the image below:

fvm list result image

  1. Selected which Flutter SDK version to use by running fvm use 1.22.0 (in my case 1.22.0, it may differ according to your desired version) command, It will download SDK if it is not installed yet;
  2. Now you can check is flutter running in your project by running flutter;

Also, you can check if the Flutter SDK version set by calling again fvm list. enter image description here

The tick means, that version is running in your project.

Sought answered 7/4, 2021 at 18:55 Comment(0)
C
1

are you add "C:\flutter\bin\cache\dart-sdk\bin" to path? enter image description here

if you in windows you should run your text editor as administrator as following

enter image description here

Chickamauga answered 3/4, 2021 at 11:25 Comment(0)
P
1

Just try:
dart pub global activate fvm

Peonir answered 17/7, 2023 at 11:58 Comment(0)
C
0

Run as administrator in the project folder and the error is solved. Example:

  • administrator cmd C:\Usersers\USURIO\Documents\Flutterproject> fvm use 3.10.0 project now uses Flutter [3.10.0].
Condominium answered 16/5, 2023 at 7:9 Comment(0)
A
0

Just delete the .fvm hidden folder in the project and re-run

Alternative answered 26/7, 2023 at 1:2 Comment(0)
S
0

Add the given path in the Environment variables in the PATH section by double-clicking it and RESTART the TERMINAL. It works.

Sunday answered 16/6 at 11:37 Comment(0)
D
0

Exception in my case was

ERR : Failed to build fvm:main:
    | ../../../.pub-cache/hosted/pub.dev/win32-5.2.0/lib/src/guid.dart:32:9: Error: Type 'UnmodifiableUint8ListView' not found.
    |   final UnmodifiableUint8ListView bytes;
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^

Following commands fixed the problem

 dart pub global activate fvm

Output will be similar to below

Package fvm is currently active at version 3.0.12.
Downloading packages... . 
> args 2.5.0 (was 2.4.2)

Cache directory: /Users/sanjay.bharwani/fvm/versions Directory Size: 9.82 GB

┌─────────┬─────────┬─────────────────┬──────────────┬──────────────┬────────┬───────┐ │ Version │ Channel │ Flutter Version │ Dart Version │ Release Date │ Global │ Local │ ├─────────┼─────────┼─────────────────┼──────────────┼──────────────┼────────┼───────┤ │ 3.24.3 │ stable │ 3.24.3 │ 3.5.3 │ Sep 12, 2024 │ │ ● │ ├─────────┼─────────┼─────────────────┼──────────────┼──────────────┼────────┼───────┤ │ 3.22.2 │ stable │ 3.22.2 │ 3.4.3 │ Jun 6, 2024 │ │ │ ├─────────┼─────────┼─────────────────┼──────────────┼──────────────┼────────┼───────┤ │ 3.22.0 │ stable │ 3.22.0 │ 3.4.0 │ May 13, 2024 │ │ │

Then use

fvm flutter clean && fvm flutter pub get

Then project was build successfully.

Design answered 27/9 at 22:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.