mise 中文文档
Everything in its place, before you code.
mise-en-place /meez ahn plahs/ — 一切就位,开发前的准备工作
🛠️ 900+ 工具
一个 TOML 文件管理所有开发工具版本
🌍 自动切换
按目录自动加载对应的工具和环境变量
📋 任务运行
定义构建、测试、部署任务,并行执行
🔒 安全可靠
配置文件信任机制,敏感变量脱敏
2. 安装
一键安装
curl https://mise.run | sh
默认安装到 ~/.local/bin
验证安装
mise --version
mise doctor # 诊断检查
其他安装方式
| 方式 | 命令 |
|---|---|
| macOS | brew install mise |
| Ubuntu/Debian | apt install mise |
| Nix | nix-env -iA nixpkgs.mise |
3. 快速上手
步骤一:激活 mise
# Bash
echo 'eval "$(~/.local/bin/mise activate bash)"' >> ~/.bashrc
# Zsh
echo 'eval "$(~/.local/bin/mise activate zsh)"' >> ~/.zshrc
重启 shell 后运行 mise doctor 验证。
步骤二:安装工具
mise use node@24 python@3.12 terraform@1
mise install
步骤三:设置环境变量
# mise.toml
[env]
NODE_ENV = "production"
DATABASE_URL = "postgres://localhost/orders"
步骤四:定义任务
# mise.toml
[tasks.hello]
run = "echo hello from mise"
[tasks.test]
run = "pytest"
mise run hello # hello from mise
mise run test # 运行 pytest
4. 核心概念
配置层级
mise 使用分层配置,从全局到局部逐级覆盖:
| 路径 | 说明 | 优先级 |
|---|---|---|
/etc/mise/config.toml | 系统级 | 最高 |
~/.config/mise/config.toml | 用户全局 | |
~/work/mise.toml | 工作目录 | |
~/work/project/mise.toml | 项目配置 | |
~/work/project/mise.local.toml | 本地覆盖(不入 Git) | 最低 |
合并规则:工具和环境变量是叠加覆盖;任务是完全替换。
信任机制
mise trust # 信任当前目录配置
mise settings trusted_config_paths=["/"] # 全局禁用提示
激活方式
| 方式 | 说明 | 适用 |
|---|---|---|
mise activate | Hook 进 shell,自动切换 | 交互式(推荐) |
| Shims | 符号链接拦截命令 | CI/CD、IDE |
mise exec | 按需使用 | 临时命令 |
5. 配置文件详解
完整示例
# 最低 mise 版本要求
min_version = '2024.11.1'
[tools]
node = '24'
python = '3.12'
ruby = 'latest'
terraform = { version = "1", postinstall = "terraform -install-autocomplete" }
[env]
NODE_ENV = 'development'
API_URL = 'http://localhost:3000'
[tasks.dev]
description = "启动开发服务器"
run = 'npm run dev'
[tasks.test]
description = "运行测试"
run = 'pytest'
depends = ["lint"]
[shell_alias]
ll = "ls -la"
gs = "git status"
版本范围语法
| 语法 | 说明 |
|---|---|
node@24 | 主版本 24 的最新版 |
node@24.1 | 24.1.x 最新版 |
node@24.1.0 | 精确版本 |
node@latest | 最新版本 |
node@lts | LTS 版本 |
ref:master | 从 Git ref 编译 |
6. 开发工具管理
常用命令
mise use node@24 # 安装并写入配置
mise use --global node@24 # 写入全局配置
mise install node@24 # 仅安装
mise exec node@24 -- node -v # 一次性执行
mise x python@3 -- python # 同上(简写)
mise ls # 列出所有工具
mise ls --current # 列出当前生效版本
mise uninstall node@24 # 卸载
按操作系统限制
[tools]
ripgrep = { version = "latest", os = ["linux", "macos"] }
hk = { version = "latest", os = ["linux", "macos/arm64"] }
工具依赖 & 安装后命令
[tools]
python = "3.12"
"pipx:ruff" = { version = "latest", depends = ["python"] }
node = { version = "22", postinstall = "corepack enable" }
7. 环境变量管理
基本用法
[env]
NODE_ENV = "production"
DATABASE_URL = "postgres://localhost/mydb"
DEBUG = false # 清除变量
CLI 操作
mise set NODE_ENV=development
mise set # 查看所有
mise unset NODE_ENV
从文件加载
[env]
_.file = '.env'
_.file = '.env.yaml' # 支持 YAML/JSON
_.file = ['.env', '.env.local'] # 多文件
_.file = { path = ".secrets", redact = true }
PATH 管理
[env]
_.path = './bin'
_.path = ['~/.local/bin', './node_modules/.bin']
模板 & 必填 & 脱敏
[env]
MY_PROJ_LIB = "{{config_root}}/lib"
LD_LIBRARY_PATH = "/some/path:{{env.MY_PROJ_LIB}}"
DATABASE_URL = { required = "设置数据库连接字符串" }
SECRET = { value = "my_secret", redact = true }
# 批量脱敏
redactions = ["SECRET_*", "*_TOKEN"]
8. 任务运行器
TOML 任务
[tasks.build]
description = "构建项目"
run = "cargo build"
[tasks.test]
description = "运行所有测试"
run = "pytest"
depends = ["lint"]
[tasks.deploy]
description = "部署到生产"
run = "kubectl apply -f k8s/"
depends = ["build", "test"]
mise run build
mise run test
mise run deploy
文件任务
创建 mise-tasks/build:
#!/usr/bin/env bash
#MISE description="Build the CLI"
cargo build
任务环境变量
| 变量 | 说明 |
|---|---|
MISE_ORIGINAL_CWD | 运行时工作目录 |
MISE_CONFIG_ROOT | 配置文件目录 |
MISE_PROJECT_ROOT | 项目根目录 |
MISE_TASK_NAME | 任务名 |
9. 后端系统
| 后端 | 说明 | 示例 |
|---|---|---|
| core | 内置主流语言 | node, python, ruby |
| npm | npm 包 | npm:@anthropic-ai/claude-code |
| pipx | Python pipx | pipx:black |
| cargo | Rust cargo | cargo:ripgrep |
| go | Go 模块 | go:golang.org/x/tools/... |
| gem | Ruby gem | gem:rails |
| github | GitHub Releases | github:BurntSushi/ripgrep |
| asdf | asdf 插件 | asdf:erlang |
| aqua | Aqua 生态 | aqua:cli/cli |
| ubi | Universal Binary | ubi:BurntSushi/ripgrep |
| http | HTTP 下载 | http:example.com/tool.tar.gz |
| vfox | vfox 插件 | vfox:nodejs |
10. 常用命令速查
# === 安装与配置 ===
mise install # 安装配置中所有工具
mise use <tool>@<ver> # 安装并写入配置
mise use -g <tool>@<ver> # 全局安装
mise uninstall <tool>@<ver> # 卸载
mise ls / mise ls --current # 列出工具
mise doctor # 诊断检查
mise trust # 信任配置
# === 执行与运行 ===
mise exec <tool>@<v> -- <cmd> # 指定工具执行
mise x <tool>@<v> -- <cmd> # 同上简写
mise run <task> # 运行任务
mise tasks ls # 列出任务
# === 环境变量 ===
mise set KEY=VALUE # 设置
mise set # 查看
mise unset KEY # 删除
mise env / mise env --json # 导出
# === 其他 ===
mise config # 配置加载顺序
mise settings # 查看设置
mise activate <shell> # 激活脚本
基于 mise 官方文档 https://mise.en.dev/ 整理 · 2026-04-28