Mise-工具管理Skill mise-tool-management

Mise是一个统一的开发工具版本管理工具,用于安装、配置和管理多种编程语言和基础设施工具的版本。它支持跨项目统一管理、灵活的版本策略,并能替代其他版本管理器如asdf、nvm、pyenv,提高开发效率和环境一致性。关键词:Mise、工具管理、版本控制、开发环境、DevOps、配置管理。

DevOps 0 次安装 0 次浏览 更新于 3/25/2026

name: mise-tool-management user-invocable: false description: 使用Mise管理开发工具版本时使用。涵盖安装工具、版本固定和替换特定语言的版本管理器。 allowed-tools:

  • Read
  • Write
  • Edit
  • Bash
  • Grep
  • Glob

Mise - 工具管理

使用Mise作为统一版本管理器,跨项目管理开发工具版本。

基本工具安装

安装工具

# 安装特定版本
mise install node@20.10.0
mise install python@3.12.0
mise install rust@1.75.0

# 安装最新版本
mise install node@latest
mise install python@latest

# 从.tool-versions或mise.toml安装
mise install

设置工具版本

# 设置全局版本
mise use --global node@20

# 设置项目版本
mise use node@20.10.0
mise use python@3.12 rust@1.75

# 使用最新版本
mise use node@latest

mise.toml中的工具配置

基本工具定义

# mise.toml
[tools]
node = "20.10.0"
python = "3.12.0"
rust = "1.75.0"
terraform = "1.6.0"

版本前缀

[tools]
# 最新补丁版本
node = "20.10"

# 最新次要版本
node = "20"

# 最新版本
node = "latest"

# 前缀表示法
terraform = "1.6"  # 最新1.6.x

多个版本

[tools]
# 使用多个版本
node = ["20.10.0", "18.19.0"]
python = ["3.12", "3.11", "3.10"]
# 在版本之间切换
mise shell node@18.19.0

工具特定配置

Node.js配置

[tools]
node = { version = "20.10.0", postinstall = "corepack enable" }

使用虚拟环境的Python

[tools]
python = "3.12"

[env]
_.python.venv = { path = ".venv", create = true }

自定义工具来源

[tools]
# 从特定注册表
"cargo:eza" = "latest"
"npm:typescript" = "5.3"

# 从git仓库
my-tool = "git:https://github.com/org/tool.git"

支持的语言和工具

核心工具

[tools]
# 语言
bun = "1.0"
deno = "1.38"
elixir = "1.15"
erlang = "26.1"
go = "1.21"
java = "21"
node = "20.10"
python = "3.12"
ruby = "3.3"
rust = "1.75"
zig = "0.11"

# 基础设施
terraform = "1.6"
kubectl = "1.28"
awscli = "2.13"

包管理器

[tools]
"npm:pnpm" = "8.10"
"npm:yarn" = "4.0"
"cargo:cargo-binstall" = "latest"
"go:github.com/golangci/golangci-lint/cmd/golangci-lint" = "latest"

工具版本策略

锁定特定版本

# 生产:固定确切版本
[tools]
node = "20.10.0"
terraform = "1.6.4"

使用范围以提高灵活性

# 开发:使用次要版本范围
[tools]
node = "20"      # 任何20.x
python = "3.12"  # 任何3.12.x

用于实验的最新版本

# 实验项目
[tools]
rust = "latest"
bun = "latest"

管理工具别名

创建别名

# 为当前目录设置别名
mise alias set node lts 20.10.0

# 设置全局别名
mise alias set --global python3 python@3.12

在配置中使用别名

[tools]
node = "lts"
python = "3.12"

工具验证

检查已安装工具

# 列出已安装工具
mise list

# 检查当前版本
mise current

# 验证工具安装
mise doctor

工具信息

# 显示工具详细信息
mise ls-remote node

# 列出可用版本
mise ls-remote python

# 检查最新版本
mise latest node

从其他版本管理器迁移

从asdf迁移

# Mise读取.tool-versions文件
cat .tool-versions
# nodejs 20.10.0
# python 3.12.0

# 迁移到mise.toml
mise use node@20.10.0 python@3.12.0

从nvm迁移

# 从.nvmrc读取
cat .nvmrc
# 20.10.0

mise use node@$(cat .nvmrc)

从pyenv迁移

# 从.python-version读取
mise use python@$(cat .python-version)

最佳实践

固定生产依赖

# 好:明确的生产版本
[tools]
node = "20.10.0"
terraform = "1.6.4"
postgres = "16.1"

记录所需工具

# mise.toml - 所有项目依赖集中管理
[tools]
node = "20.10.0"
python = "3.12.0"
terraform = "1.6.4"
kubectl = "1.28.0"

[env]
PROJECT_NAME = "my-app"

使用工具特定设置

[tools]
# 启用包管理器的corepack
node = { version = "20.10.0", postinstall = "corepack enable" }

# 创建Python虚拟环境
python = { version = "3.12", venv = ".venv" }

验证工具安装

# 在CI/CD流水线中
mise install --check
mise doctor

# 验证特定工具
mise current node
mise current python

常见模式

单仓库工具管理

# 根mise.toml - 共享工具
[tools]
node = "20.10.0"
terraform = "1.6.4"

# packages/api/mise.toml - 额外工具
[tools]
"npm:typescript" = "5.3"
"npm:prisma" = "5.7"

# packages/web/mise.toml
[tools]
"npm:next" = "14.0"

开发与生产

# mise.toml - 生产工具
[tools]
node = "20.10.0"
postgres = "16.1"

# mise.local.toml - 开发工具(git忽略)
[tools]
"npm:nodemon" = "latest"
"cargo:cargo-watch" = "latest"

工具更新策略

# 检查更新
mise outdated

# 更新到最新补丁版本
mise upgrade node

# 更新所有工具
mise upgrade

# 带约束的更新
mise use node@20  # 更新到最新20.x

反模式

不要混合版本管理器

# 坏:使用多个版本管理器
nvm use 20
mise use node@20  # 冲突

# 好:只使用Mise
mise use node@20

不要硬编码工具路径

# 坏:硬编码路径
/Users/me/.local/share/mise/installs/node/20.10.0/bin/node

# 好:使用mise shims或mise exec
mise exec -- node
mise x -- node

不要跳过版本约束

# 坏:未指定版本
[tools]
node = "latest"  # 更新时可能中断

# 好:指定约束
[tools]
node = "20.10.0"  # 明确
# 或
node = "20"  # 受控范围

不要忽略工具依赖

# 坏:缺少必需工具
[tools]
terraform = "1.6"
# 缺少:kubectl、helm用于部署

# 好:包含所有依赖
[tools]
terraform = "1.6.4"
kubectl = "1.28.0"
helm = "3.13.0"

高级模式

条件工具安装

[tools]
# 基于平台安装
node = "20.10.0"
python = "3.12"

# 平台特定工具
[tools."cargo:watchexec-cli"]
platforms = ["linux", "darwin"]
version = "latest"

工具安装钩子

[tools]
node = {
  version = "20.10.0",
  postinstall = '''
    corepack enable
    npm install -g npm@latest
  '''
}

后端选择

# 为工具使用特定后端
[tools]
# 使用核心后端(更快)
node = "core:20.10.0"

# 使用asdf插件
ruby = "asdf:3.3.0"

相关技能

  • task-configuration:定义使用管理工具的任务
  • environment-management:管理环境变量与工具