Installing and managing many development environment tools and keeping them aligned within teams can be a pain. Mise to the rescue!
Install
curl https://mise.run | sh
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
Make sure you restart your shell session after modifying your rc file in order for it to take effect
Install details
The install script will download the binary to ~/.local/bin/mise{:sh}.
Activating allows mise to add itself to the PATH and register a shell hook to run mise hook-env every time the shell prompt is displayed.
Adding mise activation in other shells:
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
echo '~/.local/bin/mise activate fish | source' >> ~/.config/fish/config.fish
Install Global Tools
mise use -g node pnpm@9 go@latest
Install global tools details
mise use{:sh} will install and activate the tools so it is available to use immediately. The -g{:sh} flag globally installs tools so they are available anywhere they are not overwritten by "local" tools.
We can run go version{:sh} (and equivalent for the other tools) now and see we have the latest (at the time of writing) go version go1.22.5 darwin/arm64{:sh}
The global configuration is saved in ~/.config/mise/config.toml{:sh}.
Install Directory Tools
touch .mise.toml
mise use node@20
mise use pnpm
Install directory tools details
Once we create a .mise.toml{:sh} file in the root of our project we can use the same mise use{:sh} (without the -g{:sh} flag) commands to install tools specific for that project. This will update the current directory .mise.toml{:sh} file configuration.
Users who encounter an existing .mise.toml{:sh} file simply run mise install{:sh} to get all tools listed in the config with the correct versions.
When not in our project directory, the global version of node (latest) will be used but when we cd{:sh} into our project directory with .mise.toml{:sh} node version 20 will be used. Try printing the version to see for yourself in different directories.
Globally we might live on the edge and install the latest node{:sh} version but for this specific project, we are using the long-term support (lts) version.
Shims
mise updates the PATH every time the shell prompt is displayed. In non-interactive use cases where there is no shell prompt, the PATH is not updated. Shims gives us access to the mise tools in non-interactive environments.
I use starship as a shell prompt so I install it globally:
mise use -g starship
For starship to work, we need to initialise it by adding the following line to ~/.zshrc{:sh}
eval "$(starship init zsh)"
But this will not work because .zshrc{:sh} has run in a non-interactive session (and no prompt displayed) and mise has not been able to add starship to the PATH. mise provides shims for the tools in ~/.local/share/mise/shims so we can change our .zshrc{:sh} command to use the mise starship shim and we are good to go.
eval "$(~/.local/share/mise/shims/starship init zsh)"
Other Useful Commands
mise ls-remote go
mise ls
mise self-update
mise doctor