fenv
is a CLI tool that helps manage multiple versions of flutter SDKs in
your local machine. fenv
does never require any other dependencies because
it is implemented with bash
only.
This is a premature hobby project and currently work-in-progress.
This project is highly inspired by pyenv, which are mostly implemented with
bash
scripts.
- Execute the following command in your terminal:
$ curl -sSL "https://raw.githubusercontent.com/powdream/fenv/main/init.sh" \ | sh -
- If you install
fenv
for the first time in your machine, then, you will see instruction like:# Please execute the following command and following instructions if you have not setup `fenv` yet: $HOME/.fenv/bin/fenv init
- Execute
$HOME/.fenv/bin/fenv init
then follow the next instructions:- zsh:
# Load fenv automatically by appending # the following to ~/.zprofile (for login shells) and ~/.zshrc (for interactive shells) : export FENV_ROOT="$HOME/.fenv" command -v fenv >/dev/null || export PATH="$FENV_ROOT/bin:$PATH" eval "$(fenv init -)" # Restart your shell for the changes to take effect. exec $SHELL -l
- bash:
# Load fenv automatically by appending`` # the following to ~/.bash_profile if it exists, otherwise ~/.profile (for login shells) and ~/.bashrc (for interactive shells) : export FENV_ROOT="$HOME/.fenv" command -v fenv >/dev/null || export PATH="$FENV_ROOT/bin:$PATH" eval "$(fenv init -)" # Restart your shell for the changes to take effect. exec $SHELL -l
- fish:
# Add fenv executable to PATH by running # the following interactively: set -Ux FENV_ROOT $HOME/.fenv fish_add_path $FENV_ROOT/bin # Load fenv automatically by appending # the following to ~/.config/fish/conf.d/fenv.fish: fenv init - | source # Restart your shell for the changes to take effect. exec $SHELL -l
- zsh:
- Remove
FLUTTER_HOME
,FLUTTER_SDK
environmental variables if exist. - Eliminate any existing
<FLUTTER_SDK>/bin
from yourPATH
.
- List-up available flutter SDKs.
$ fenv install -l
- Install any flutter SDK you want.
$ fenv install <version> $ fenv versions <version>
- Select the download SDK as the globally-using flutter SDK.
$ fenv global <version> $ fenv version <version> (set by $HOME/.fenv/version)
- Test if
flutter
is working correctly:$ flutter --version $ fenv which flutter
- CD to your flutter project directory and specify local version:
$ cd PROJECT $ fenv local <local-version>
fenv
will generate the following two files.flutter-version
and.flutter
symbolic link, which is a link to$HOME/.fenv/versions/<local-version>
.- Test if
flutter
is working correctly:$ fenv version $ fenv which flutter $ flutter --version
- We recommend staging
.flutter-version
to VCS, but not.flutter
. - After change your local flutter version, do
flutter clean
and re-launch VS code.
- If you run into an error message like:
$ flutter fenv: no installed versions match the prefix '{VERSION}': try to execute 'fenv install && fenv local --symlink'
- Then, following the instruction, please execute:
or
$ fenv install $ fenv local --symlink
$ fenv install && fenv local --symlink
- If you are using
fenv local
, please check if.flutter
symlink is installed. If.flutter
is not installed yet,fenv
will let you know you need to executefenv local --symlink[-s]
. - If you are using
fenv global
, please runflutter pub get
once and re-launch VS code.