DEV Community

Cover image for How to use mise with FVM?
Naomi Watanabe
Naomi Watanabe

Posted on • Originally published at Medium

How to use mise with FVM?

In Flutter, FVM is the primary Flutter version management tool. But what should we do when the monorepo or any other language project is involved? Should we use proper tools respectively?

I recommend using mise in that case.

Here, I focus on introducing how to use mise in FVM project. If you can start the Flutter project with mise, you do not need FVM. You can run the mise use command or add the mise config file and run mise i as well.

Before we get to the main points, describe this tool briefly.

What is mise?

According to the official document, mise, formerly called rtx, is a development environment setup tool, and one of its functionality is this:

mise installs and manages dev tools/runtimes like node, python, or terraform both simplifying installing these tools and allowing you to specify which version of these tools to use in different projects. mise supports hundreds of dev tools.

In short, mise is suitable for people who use various languages and projects with multiple components like front-end, back-end, or something.

If you would like more information, check out the official site!

mise.jdx.dev

Let's get started!

1. Uninstall FVM

Unfortunately, we can not use mise and FVM together. To start using mise, we need to remove FVM:

fvm destroy
Enter fullscreen mode Exit fullscreen mode

or if you installed using pub:

dart pub global deactivate fvm
Enter fullscreen mode Exit fullscreen mode

FAQ – FVM

2. Uninstall Flutter

We will install Flutter using mise and use it in each Flutter project. If you already have the Flutter SDKs installed, remove them to avoid conflict.

rm -rf path/to/flutter
rm -rf  ~/.flutter*
Enter fullscreen mode Exit fullscreen mode

Make sure to remove PATH as well.

Uninstall Flutter | Flutter

3. Install mise and Flutter plugin

Mise provides many ways to install, depending on your environment. Please follow the installation steps that suit you. Use Homebrew here:

brew install mise
Enter fullscreen mode Exit fullscreen mode

Getting Started | mise-en-place

Then, install the Flutter plugin made by nyuyuyu. Be sure to install a plugin that supports FVM; the one in the mise plugin repositories does not.

mise plugin install flutter https://github.com/nyuyuyu/asdf-flutter.git
Enter fullscreen mode Exit fullscreen mode

GitHub logo nyuyuyu / asdf-flutter

Flutter plugin for the asdf version manager

asdf-flutter Build Lint

Flutter plugin for the asdf version manager.

Contents

Dependencies

  • bash, curl, tar: generic POSIX utilities.
  • jq: recommended.
  • xz: only required for Linux.

Install

Plugin:

asdf plugin add flutter https://github.com/nyuyuyu/asdf-flutter.git
Enter fullscreen mode Exit fullscreen mode

flutter:

# Show all installable versions
asdf list-all flutter

# Install specific version
asdf install flutter latest

# Set a version globally (on your ~/.tool-versions file)
asdf global flutter latest

# Now flutter commands are available
flutter --help
Enter fullscreen mode Exit fullscreen mode

Check asdf readme for more instructions on how to install & manage versions.

Support fvm

If you have set legacy_version_file = yes in $HOME/.asdfrc, you can read the Flutter version from .fvmrc or .fvm/fvm_config.json, the fvm configuration file.

Troubleshooting

VS Code

image

To fix the "Could not find a Flutter SDK" error, you can set the FLUTTER_ROOT environment variable in your .bashrc or .zshrc file:

export FLUTTER_ROOT="
Enter fullscreen mode Exit fullscreen mode

Bonus (for VSCode users): Add SDK paths in settings.json:

"dart.flutterSdkPaths": [
  "~/.local/share/mise/installs/flutter"
],
"dart.sdkPaths": [
  "~/.local/share/mise/installs/flutter"
],
Enter fullscreen mode Exit fullscreen mode

That's it!

Now, we can use mise with FVM, specifically the FVM config file. Simply running the command mise i works perfectly.

Happy coding!

Top comments (0)