Stefan Xenopol
3 months
Claus-Theodor Riegg
9 years
Claus-Theodor Riegg
8 years
Claus-Theodor Riegg
7 years
Stefan Langenmaier
1 year

Updated: HowTo: switch to mise from asdf

Posted . Visible to the public. Auto-destruct in 59 days

Goodbye direnv 👋

Changes

  • # Add apt source:
  • ```bash
  • apt update -y && apt install -y gpg sudo wget curl
  • sudo install -dm 755 /etc/apt/keyrings
  • wget -qO - https://mise.jdx.dev/gpg-key.pub | gpg --dearmor | sudo tee /etc/apt/keyrings/mise-archive-keyring.gpg 1> /dev/null
  • echo "deb [signed-by=/etc/apt/keyrings/mise-archive-keyring.gpg arch=amd64] https://mise.jdx.dev/deb stable main" | sudo tee /etc/apt/sources.list.d/mise.list
  • sudo apt update
  • sudo apt install -y mise
  • ```
  • # Configure Shell
  • You don't have to add it to `PATH`, the following command does that for you
  • ## Bash:
  • ```shell
  • echo 'eval "$(mise activate bash)"' >> ~/.bashrc
  • ```
  • ## ZSH:
  • ```shell
  • echo 'eval "$(mise activate zsh)"' >> ~/.zshrc
  • ```
  • ## Remove `asdf`
  • Of course you'll have to remove any mention of `asdf` from your shell config. After you're confident you don't need the `asdf` setup any more, you can delete `$HOME/.asdf` as well.
  • ## Shell addons
  • If you rely on things installed via `mise` for your shell setup, e.g. `starship`
  • to have a nicer prompt, you'll find that it won't work out of the box. The reason
  • is that [`mise` only updates your `$PATH` _when the prompt is being displayed_](https://mise.jdx.dev/faq.html#mise-isn-t-working-when-calling-from-tmux-or-another-shell-initialization-script)).
  • For these commands you can call `mise` explicitly in your shell config:
  • ```shell
  • eval "$(mise exec starship -- starship init zsh)"
  • ```
  • Where the first `starship` is the name of the `mise`/`asdf` plugin and the second one is the name of the plugin we're calling.
  • # Install tools
  • `mise` will re-use `.tool-versions` files in your home directory or in project directories. It will not, however, re-use tools installed by `asdf`. It _is_ possible to just let `mise` use the files downloaded by `asdf` by moving the directories around but it's not officially supported. It's probably faster to just `mise install` everything than debugging what went wrong.
  • ## Install global plugins
  • If you had any tools installed globally, you can just re-install these by `cd`ing to your home directory and running `mise install`.
  • ## Install local plugins
  • For each project that has a `.tool-versions`, you'll have to run `mise install` again. `mise` will tell you which plugins are missing on `cd`ing to the directory though.
  • # Upgrade tools
  • Upgrading tools works with `mise upgrade` or `mise up`, but won't work with pinned version numbers in `.tool-versions`. For tools used globally, migration from `.tool-versions` to a mise config file (which supports `latest` as a version string) is easy:
  • ```shell
  • $ mkdir -p ~/.config/mise/config.toml
  • $ echo '[tools]' > ~/.config/mise/config.toml
  • $ sed -i 's/\([^ ]*\).*/\1 = "latest"/' .tool-versions >> ~/.config/mise/config.toml
  • ```
  • Now you can just run `mise upgrade` and it will bring all your tools to the latest version.
  • +
  • +# Replace `direnv`
  • +
  • +Both [`direnv`](https://direnv.net/) and `mise` handle environment variables. For switching use:
  • +
  • +```shell
  • +$ direnv disallow
  • +$ cat `.envrc`
  • +export FOO=bar
  • +
  • +$ mise set FOO=bar --file mise.local.toml
  • +$ chmod 0600 mise.local.toml
  • +```
Andreas Vöst
License
Source code in this card is licensed under the MIT License.