mise 使用
安装 mise
在 macOS 或 Linux 上,你可以通过以下方式安装:
curl https://mise.jdx.dev/install.sh | sh
激活 Shell (至关重要)
为了让 mise 能够在你进入项目目录时自动切换版本,你需要将其集成到你的 Shell 中。请根据你使用的 Shell 选择:
- Zsh: 在
~/.zshrc末尾添加:
eval "$(mise activate zsh)"
- Fish: 在
~/.config/fish/config.fish末尾添加:
mise activate fish | source
- Bash: 在
~/.bashrc末尾添加:
eval "$(mise activate bash)"
注意:配置完成后,请重启终端或运行
source命令使配置生效。
安装工具
比如我想安装 rg 这个工具。
先搜索 mise 是否支持
mise registry rg
如果命中,会输出该工具对应的 backend 列表,例如:
aqua:BurntSushi/ripgrep asdf:https://gitlab.com/wt0f/asdf-ripgrep
cargo:ripgrep
第一个就是 mise 默认会使用的 backend(backend 可以理解成下载源)。
如果没命中(tool not found in registry),可以:
• 模糊搜索:mise registry | rg ripgrep
• 在 GitHub 找到项目本身,用 github:owner/repo backend 直装
查看可用版本(可选)
mise ls-remote rg | tail
确认是否有你想要的版本,比如要装 14.x。
安装
临时试用(只装,不写入配置):
mise install rg@latest
全局使用(写入 ~/.config/mise/config.toml,PATH 自动生效):
mise use -g rg@latest
# 或固定版本
mise use -g rg@14.1.1
mise use -g 会同时完成「安装 + 写入全局配置」。
只想用在当前项目目录使用:
mise use rg@latest # 写入当前目录的 mise.toml
验证
mise which rg
rg --version
后续维护
mise ls rg # 查看已安装版本
mise upgrade rg # 升级
mise uninstall rg # 卸载
Read other posts