mise
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemise - Development Environment Management
mise - 开发环境管理
This skill activates when working with mise for managing tool versions, environment variables, and project tasks.
当你使用mise管理工具版本、环境变量和项目任务时,可启用本技能。
When to Use This Skill
何时使用本技能
Activate when:
- Setting up development environments
- Managing tool and runtime versions (Node.js, Python, Ruby, Go, etc.)
- Configuring environment variables and secrets
- Defining and running project tasks
- Creating reproducible development setups
- Working with monorepos or multiple projects
在以下场景启用:
- 搭建开发环境
- 管理工具和运行时版本(Node.js、Python、Ruby、Go等)
- 配置环境变量和密钥
- 定义并运行项目任务
- 创建可复现的开发环境
- 处理单体仓库或多项目
What is mise?
什么是mise?
mise is a polyglot runtime manager and development environment tool that combines:
- Tool version management - Install and manage multiple versions of dev tools
- Environment configuration - Set environment variables per project
- Task automation - Define and run project tasks
- Cross-platform - Works on macOS, Linux, and Windows
mise是一款多语言运行时管理器和开发环境工具,整合了以下功能:
- 工具版本管理 - 安装并管理多个版本的开发工具
- 环境配置 - 为每个项目设置环境变量
- 任务自动化 - 定义并运行项目任务
- 跨平台支持 - 可在macOS、Linux和Windows系统上运行
Installation
安装
bash
undefinedbash
undefinedmacOS/Linux (using curl)
macOS/Linux(使用curl)
curl https://mise.run | sh
curl https://mise.run | sh
macOS (using Homebrew)
macOS(使用Homebrew)
brew install mise
brew install mise
Windows
Windows
See https://mise.jdx.dev for Windows install instructions
Activate mise in your shell
在Shell中激活mise
echo 'eval "$(mise activate bash)"' >> ~/.bashrc # bash
echo 'eval "$(mise activate zsh)"' >> ~/.zshrc # zsh
echo 'mise activate fish | source' >> ~/.config/fish/config.fish # fish
undefinedecho 'eval "$(mise activate bash)"' >> ~/.bashrc # bash
echo 'eval "$(mise activate zsh)"' >> ~/.zshrc # zsh
echo 'mise activate fish | source' >> ~/.config/fish/config.fish # fish
undefinedManaging Tools
管理工具
Tool Backends
工具后端
mise uses different backends (package managers) to install tools. Understanding backends helps you install tools correctly.
mise使用不同的后端(包管理器)来安装工具。了解后端有助于你正确安装工具。
Available Backends
可用后端
- asdf - Traditional asdf plugins (default for many tools)
- ubi - Universal Binary Installer (GitHub/GitLab releases)
- cargo - Rust packages (requires Rust installed)
- npm - Node.js packages (requires Node installed)
- go - Go packages (requires Go installed)
- aqua - Package manager
- pipx - Python packages (requires Python installed)
- gem - Ruby packages (requires Ruby installed)
- github/gitlab - Direct from repositories
- http - Direct HTTP downloads
- asdf - 传统asdf插件(许多工具的默认后端)
- ubi - 通用二进制安装器(从GitHub/GitLab发布版安装)
- cargo - Rust包(需要预先安装Rust)
- npm - Node.js包(需要预先安装Node)
- go - Go包(需要预先安装Go)
- aqua - 包管理器
- pipx - Python包(需要预先安装Python)
- gem - Ruby包(需要预先安装Ruby)
- github/gitlab - 直接从仓库安装
- http - 直接通过HTTP下载安装
Verifying Tool Names
验证工具名称
Always verify tool names using before adding to configuration:
mise ls-remotebash
undefined在添加到配置之前,务必使用验证工具名称:
mise ls-remotebash
undefinedCheck if tool exists in registry
检查工具是否在注册表中存在
mise ls-remote node
mise ls-remote node
Check tool with specific backend
检查使用特定后端的工具
mise ls-remote cargo:ripgrep
mise ls-remote ubi:sharkdp/fd
mise ls-remote cargo:ripgrep
mise ls-remote ubi:sharkdp/fd
Search the registry
搜索注册表
mise registry | grep <tool-name>
undefinedmise registry | grep <tool-name>
undefinedInstalling Tools
安装工具
bash
undefinedbash
undefinedList available tools in registry
列出注册表中的可用工具
mise registry
mise registry
Install from default backend
从默认后端安装
mise install node@20.10.0
mise install python@3.12
mise install ruby@3.3
mise install node@20.10.0
mise install python@3.12
mise install ruby@3.3
Install with specific backend
使用特定后端安装
mise install cargo:ripgrep # From Rust crates
mise install ubi:sharkdp/fd # From GitHub releases
mise install npm:typescript # From npm
mise install cargo:ripgrep # 从Rust crates安装
mise install ubi:sharkdp/fd # 从GitHub发布版安装
mise install npm:typescript # 从npm安装
Install latest version
安装最新版本
mise install node@latest
mise install node@latest
Install from .mise.toml or .tool-versions
从.mise.toml或.tool-versions安装
mise install
undefinedmise install
undefinedUsing Tools with mise use
mise use使用mise use
管理工具
mise useThe command is the primary way to add tools to projects. It combines two operations:
mise use- Installs the tool (if not already installed)
- Adds the tool to your configuration file
Key Difference: only installs tools, while installs AND configures them.
mise installmise usemise use- 安装工具(如果尚未安装)
- 添加工具到你的配置文件
关键区别:仅安装工具,而会安装并配置工具。
mise installmise useBasic Usage
基础用法
bash
undefinedbash
undefinedInteractive selection
交互式选择
mise use
mise use
Add tool with fuzzy version (default)
添加模糊版本的工具(默认)
mise use node@20 # Saves as "20" in mise.toml
mise use node@20 # 在mise.toml中保存为"20"
Add tool with exact version
添加精确版本的工具
mise use --pin node@20.10.0 # Saves as "20.10.0"
mise use --pin node@20.10.0 # 在mise.toml中保存为"20.10.0"
Add latest version
添加最新版本
mise use node@latest # Saves as "latest"
mise use node@latest # 在mise.toml中保存为"latest"
Add with specific backend
使用特定后端添加
mise use cargo:ripgrep@latest
mise use ubi:sharkdp/fd
undefinedmise use cargo:ripgrep@latest
mise use ubi:sharkdp/fd
undefinedConfiguration File Selection
配置文件选择
mise use- flag:
--global~/.config/mise/config.toml - flag: Specified file path
--path <file> - flag:
--env <env>.mise.<env>.toml - Default: in current directory
mise.toml
bash
undefinedmise use- 参数:
--global~/.config/mise/config.toml - 参数:指定的文件路径
--path <file> - 参数:
--env <env>.mise.<env>.toml - 默认:当前目录下的
mise.toml
bash
undefinedGlobal (all projects)
全局配置(所有项目)
mise use --global node@20
mise use --global node@20
Local (current project)
本地配置(当前项目)
mise use node@20 # Creates/updates ./mise.toml
mise use node@20 # 创建/更新./mise.toml
Environment-specific
特定环境配置
mise use --env local node@20 # Creates .mise.local.toml
mise use --env local node@20 # 创建.mise.local.toml
Specific file
指定文件
mise use --path ~/.config/mise/custom.toml node@20
undefinedmise use --path ~/.config/mise/custom.toml node@20
undefinedImportant Flags
重要参数
bash
undefinedbash
undefinedPin exact version
固定精确版本
mise use --pin node@20.10.0 # Saves "20.10.0"
mise use --pin node@20.10.0 # 保存为"20.10.0"
Fuzzy version (default)
模糊版本(默认)
mise use --fuzzy node@20 # Saves "20"
mise use --fuzzy node@20 # 保存为"20"
Force reinstall
强制重新安装
mise use --force node@20
mise use --force node@20
Dry run (preview changes)
试运行(预览更改)
mise use --dry-run node@20
mise use --dry-run node@20
Remove tool from config
从配置中移除工具
mise use --remove node
undefinedmise use --remove node
undefinedVersion Pinning
版本固定
bash
undefinedbash
undefinedFuzzy (recommended) - auto-updates within major version
模糊版本(推荐)- 在大版本内自动更新
mise use node@20 # Uses latest 20.x.x
mise use node@20 # 使用最新的20.x.x版本
Exact - locks to specific version
精确版本 - 锁定到特定版本
mise use --pin node@20.10.0 # Always uses 20.10.0
mise use --pin node@20.10.0 # 始终使用20.10.0
Latest - always uses newest version
最新版本 - 始终使用最新版本
mise use node@latest # Always updates to latest
**Best Practice**: Use fuzzy versions for flexibility, `mise.lock` for reproducibility.mise use node@latest # 始终更新到最新版本
**最佳实践**:使用模糊版本以保持灵活性,使用`mise.lock`确保可复现性。Setting Tool Versions
设置工具版本
The command automatically sets tool versions by updating configuration files.
mise usemise use.mise.toml Configuration
.mise.toml配置示例
toml
[tools]
node = "20.10.0"
python = "3.12"
ruby = "3.3"
go = "1.21"toml
[tools]
node = "20.10.0"
python = "3.12"
ruby = "3.3"
go = "1.21"Use latest version
使用最新版本
terraform = "latest"
terraform = "latest"
Backends - use quotes for namespaced tools
后端 - 为命名空间工具使用引号
"cargo:ripgrep" = "latest" # Requires rust installed
"ubi:sharkdp/fd" = "latest" # GitHub releases
"npm:typescript" = "latest" # Requires node installed
"cargo:ripgrep" = "latest" # 需要预先安装Rust
"ubi:sharkdp/fd" = "latest" # GitHub发布版
"npm:typescript" = "latest" # 需要预先安装Node
Version from file
从文件获取版本
node = { version = "lts", resolve = "latest-lts" }
undefinednode = { version = "lts", resolve = "latest-lts" }
undefinedUBI Backend (Universal Binary Installer)
UBI后端(通用二进制安装器)
The ubi backend installs tools directly from GitHub/GitLab releases without requiring plugins. It's built into mise and works cross-platform including Windows.
ubi后端直接从GitHub/GitLab发布版安装工具,无需插件。它内置在mise中,支持跨平台,包括Windows。
Basic UBI Usage
UBI基础用法
bash
undefinedbash
undefinedInstall from GitHub releases
从GitHub发布版安装
mise use -g ubi:goreleaser/goreleaser
mise use -g ubi:sharkdp/fd
mise use -g ubi:BurntSushi/ripgrep
mise use -g ubi:goreleaser/goreleaser
mise use -g ubi:sharkdp/fd
mise use -g ubi:BurntSushi/ripgrep
Specific version
安装特定版本
mise use -g ubi:goreleaser/goreleaser@1.25.1
mise use -g ubi:goreleaser/goreleaser@1.25.1
In .mise.toml
在.mise.toml中配置
[tools]
"ubi:goreleaser/goreleaser" = "latest"
"ubi:sharkdp/fd" = "2.0.0"
undefined[tools]
"ubi:goreleaser/goreleaser" = "latest"
"ubi:sharkdp/fd" = "2.0.0"
undefinedUBI Advanced Options
UBI高级选项
Configure tool-specific options when binary names differ or filtering is needed:
toml
[tools]当二进制名称不同或需要过滤时,配置工具特定选项:
toml
[tools]When executable name differs from repo name
当可执行文件名称与仓库名称不同时
"ubi:BurntSushi/ripgrep" = { version = "latest", exe = "rg" }
"ubi:BurntSushi/ripgrep" = { version = "latest", exe = "rg" }
Filter releases with matching pattern
使用匹配模式过滤发布版
"ubi:some/tool" = { version = "latest", matching = "linux-gnu" }
"ubi:some/tool" = { version = "latest", matching = "linux-gnu" }
Use regex for complex filtering
使用正则表达式进行复杂过滤
"ubi:some/tool" = { version = "latest", matching_regex = ".-linux-.\.tar\.gz$" }
"ubi:some/tool" = { version = "latest", matching_regex = ".-linux-.\.tar\.gz$" }
Extract entire tarball
提取整个tar包
"ubi:some/tool" = { version = "latest", extract_all = true }
"ubi:some/tool" = { version = "latest", extract_all = true }
Rename extracted executable
重命名提取的可执行文件
"ubi:some/tool" = { version = "latest", rename_exe = "my-tool" }
undefined"ubi:some/tool" = { version = "latest", rename_exe = "my-tool" }
undefinedUBI Supported Syntax
UBI支持的语法
Three installation formats:
- GitHub shorthand (latest):
ubi:owner/repo - GitHub shorthand (version):
ubi:owner/repo@1.2.3 - Direct URL:
ubi:https://github.com/owner/repo/releases/download/v1.2.3/...
三种安装格式:
- GitHub简写(最新版本):
ubi:owner/repo - GitHub简写(指定版本):
ubi:owner/repo@1.2.3 - 直接URL:
ubi:https://github.com/owner/repo/releases/download/v1.2.3/...
Templates
模板
The directory contains reusable configuration snippets for common mise patterns.
templates/templates/Multi-Architecture Tool Installation
多架构工具安装
When installing tools from GitHub releases that provide separate binaries for different platforms/architectures, use platform-specific asset patterns.
See for the pattern:
templates/multi-arch.mdtoml
[tools."github:owner/repo"]
version = "latest"
[tools."github:owner/repo".platforms]
linux-x64 = { asset_pattern = "tool_*_linux_amd64.tar.gz" }
macos-arm64 = { asset_pattern = "tool_*_darwin_arm64.tar.gz" }当从GitHub发布版安装为不同平台/架构提供独立二进制文件的工具时,使用平台特定的资产模式。
查看获取模式示例:
templates/multi-arch.mdtoml
[tools."github:owner/repo"]
version = "latest"
[tools."github:owner/repo".platforms]
linux-x64 = { asset_pattern = "tool_*_linux_amd64.tar.gz" }
macos-arm64 = { asset_pattern = "tool_*_darwin_arm64.tar.gz" }Platform Keys
平台标识
Common platform keys for mise:
- - Linux on x86_64/amd64
linux-x64 - - Linux on ARM64/aarch64
linux-arm64 - - macOS on Intel (x86_64)
macos-x64 - - macOS on Apple Silicon (M1/M2/M3)
macos-arm64 - - Windows on x86_64
windows-x64
mise常用的平台标识:
- - x86_64/amd64架构的Linux
linux-x64 - - ARM64/aarch64架构的Linux
linux-arm64 - - Intel(x86_64)架构的macOS
macos-x64 - - Apple Silicon(M1/M2/M3)架构的macOS
macos-arm64 - - x86_64架构的Windows
windows-x64
Asset Pattern Wildcards
资产模式通配符
Use as a wildcard in asset patterns to match version numbers or other variable parts of release asset names.
*Example for a tool with releases like :
beads_1.0.0_darwin_arm64.tar.gztoml
asset_pattern = "beads_*_darwin_arm64.tar.gz"在资产模式中使用作为通配符,匹配版本号或发布资产名称中的其他可变部分。
*例如,对于发布资产类似的工具:
beads_1.0.0_darwin_arm64.tar.gztoml
asset_pattern = "beads_*_darwin_arm64.tar.gz"Cargo Backend
Cargo后端
The cargo backend installs Rust packages from crates.io. Requires Rust to be installed first.
cargo后端从crates.io安装Rust包。需要预先安装Rust。
Cargo Prerequisites
Cargo前置条件
Install Rust before using cargo backend:
bash
undefined在使用cargo后端之前,先安装Rust:
bash
undefinedOption 1: Install Rust via mise
选项1:通过mise安装Rust
mise use -g rust
mise use -g rust
Option 2: Install Rust directly
选项2:直接安装Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
undefinedcurl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
undefinedCargo Usage
Cargo用法
bash
undefinedbash
undefinedInstall from crates.io
从crates.io安装
mise use -g cargo:ripgrep
mise use -g cargo:eza
mise use -g cargo:bat
mise use -g cargo:ripgrep
mise use -g cargo:eza
mise use -g cargo:bat
In .mise.toml - requires rust installed first
在.mise.toml中配置 - 需要先安装Rust
[tools]
rust = "latest" # Install rust first
"cargo:ripgrep" = "latest" # Then cargo tools
"cargo:eza" = "latest"
"cargo:bat" = "latest"
undefined[tools]
rust = "latest" # 先安装Rust
"cargo:ripgrep" = "latest" # 然后安装cargo工具
"cargo:eza" = "latest"
"cargo:bat" = "latest"
undefinedCargo from Git Repositories
从Git仓库安装Cargo包
bash
undefinedbash
undefinedSpecific tag
特定标签
mise use cargo:https://github.com/username/demo@tag:v1.0.0
mise use cargo:https://github.com/username/demo@tag:v1.0.0
Branch
分支
mise use cargo:https://github.com/username/demo@branch:main
mise use cargo:https://github.com/username/demo@branch:main
Commit hash
提交哈希
mise use cargo:https://github.com/username/demo@rev:abc123
undefinedmise use cargo:https://github.com/username/demo@rev:abc123
undefinedCargo Settings
Cargo设置
Configure cargo behavior globally:
toml
[settings]全局配置cargo行为:
toml
[settings]Use cargo-binstall for faster installs (default: true)
使用cargo-binstall加快安装速度(默认:true)
cargo.binstall = true
cargo.binstall = true
Use alternative cargo registry
使用替代的cargo注册表
cargo.registry_name = "my-registry"
undefinedcargo.registry_name = "my-registry"
undefinedManaging Installed Tools
管理已安装的工具
bash
undefinedbash
undefinedList installed tools
列出已安装的工具
mise list
mise list
List all versions of a tool
列出某个工具的所有版本
mise list node
mise list node
Uninstall a version
卸载某个版本
mise uninstall node@18.0.0
mise uninstall node@18.0.0
Update all tools to latest
将所有工具更新到最新版本
mise upgrade
mise upgrade
Update specific tool
更新特定工具
mise upgrade node
undefinedmise upgrade node
undefinedTool Aliases
工具别名
bash
undefinedbash
undefinedCreate alias for a tool
为工具创建别名
mise alias node 20 20.10.0
mise alias node 20 20.10.0
Use alias
使用别名
mise use node@20
undefinedmise use node@20
undefinedEnvironment Variables
环境变量
Setting Environment Variables
设置环境变量
In .mise.toml
在.mise.toml中设置
toml
[env]
DATABASE_URL = "postgresql://localhost/myapp"
API_KEY = "development-key"
NODE_ENV = "development"toml
[env]
DATABASE_URL = "postgresql://localhost/myapp"
API_KEY = "development-key"
NODE_ENV = "development"Template values
模板值
APP_ROOT = "{{ config_root }}"
DATA_DIR = "{{ config_root }}/data"
undefinedAPP_ROOT = "{{ config_root }}"
DATA_DIR = "{{ config_root }}/data"
undefinedFile-based env vars
基于文件的环境变量
toml
[env]
_.file = ".env"
_.path = ["/custom/bin"]toml
[env]
_.file = ".env"
_.path = ["/custom/bin"]Environment Templates
环境变量模板
Use Go templates in environment variables:
toml
[env]
PROJECT_ROOT = "{{ config_root }}"
LOG_FILE = "{{ config_root }}/logs/app.log"
PATH = ["{{ config_root }}/bin", "$PATH"]在环境变量中使用Go模板:
toml
[env]
PROJECT_ROOT = "{{ config_root }}"
LOG_FILE = "{{ config_root }}/logs/app.log"
PATH = ["{{ config_root }}/bin", "$PATH"]Secrets Management
密钥管理
bash
undefinedbash
undefinedUse with sops
与sops配合使用
mise set SECRET_KEY sops://path/to/secret
mise set SECRET_KEY sops://path/to/secret
Use with age
与age配合使用
mise set API_TOKEN age://path/to/secret
mise set API_TOKEN age://path/to/secret
Use from command
从命令设置
mise set BUILD_ID "$(git rev-parse HEAD)"
undefinedmise set BUILD_ID "$(git rev-parse HEAD)"
undefinedTasks
任务
Defining Tasks
定义任务
In .mise.toml
在.mise.toml中定义
toml
[tasks.build]
description = "Build the project"
run = "npm run build"
[tasks.test]
description = "Run tests"
run = "npm test"
[tasks.lint]
description = "Run linter"
run = "npm run lint"
depends = ["build"]
[tasks.ci]
description = "Run CI pipeline"
depends = ["lint", "test"]
[tasks.dev]
description = "Start development server"
run = "npm run dev"toml
[tasks.build]
description = "构建项目"
run = "npm run build"
[tasks.test]
description = "运行测试"
run = "npm test"
[tasks.lint]
description = "运行代码检查"
run = "npm run lint"
depends = ["build"]
[tasks.ci]
description = "运行CI流水线"
depends = ["lint", "test"]
[tasks.dev]
description = "启动开发服务器"
run = "npm run dev"Running Tasks
运行任务
bash
undefinedbash
undefinedRun a task
运行单个任务
mise run build
mise run test
mise run build
mise run test
Short form
简写形式
mise build
mise test
mise build
mise test
Run multiple tasks
运行多个任务
mise run lint test
mise run lint test
List available tasks
列出可用任务
mise tasks
mise tasks
Run task with arguments
带参数运行任务
mise run script -- arg1 arg2
undefinedmise run script -- arg1 arg2
undefinedTask Dependencies
任务依赖
toml
[tasks.deploy]
depends = ["build", "test"]
run = "npm run deploy"toml
[tasks.deploy]
depends = ["build", "test"]
run = "npm run deploy"Tasks run in order: build, test, then deploy
任务执行顺序:build、test,然后是deploy
undefinedundefinedTask Options
任务选项
toml
[tasks.build]
description = "Build the project"
run = "npm run build"
sources = ["src/**/*.ts"] # Only run if sources changed
outputs = ["dist/**/*"] # Check outputs for changes
dir = "frontend" # Run in specific directory
env = { NODE_ENV = "production" }
[tasks.watch]
run = "npm run watch"
raw = true # Don't wrap in shelltoml
[tasks.build]
description = "构建项目"
run = "npm run build"
sources = ["src/**/*.ts"] # 仅当源文件更改时运行
outputs = ["dist/**/*"] # 检查输出文件的更改
dir = "frontend" # 在指定目录中运行
env = { NODE_ENV = "production" }
[tasks.watch]
run = "npm run watch"
raw = true # 不使用Shell包装Task Files
任务文件
Create separate task files:
bash
undefined创建独立的任务文件:
bash
undefined.mise/tasks/deploy
.mise/tasks/deploy
#!/bin/bash
#!/bin/bash
mise description="Deploy to production"
mise description="部署到生产环境"
mise depends=["build", "test"]
mise depends=["build", "test"]
echo "Deploying..."
npm run deploy
Make executable:
```bash
chmod +x .mise/tasks/deployecho "正在部署..."
npm run deploy
设置可执行权限:
```bash
chmod +x .mise/tasks/deployCommon Workflows
常见工作流
Node.js Project Setup
Node.js项目搭建
toml
undefinedtoml
undefined.mise.toml
.mise.toml
[tools]
node = "20"
[env]
NODE_ENV = "development"
[tasks.install]
run = "npm install"
[tasks.dev]
run = "npm run dev"
depends = ["install"]
[tasks.build]
run = "npm run build"
depends = ["install"]
[tasks.test]
run = "npm test"
depends = ["install"]
```bash[tools]
node = "20"
[env]
NODE_ENV = "development"
[tasks.install]
run = "npm install"
[tasks.dev]
run = "npm run dev"
depends = ["install"]
[tasks.build]
run = "npm run build"
depends = ["install"]
[tasks.test]
run = "npm test"
depends = ["install"]
```bashSetup and run
搭建并运行
cd project
mise install # Installs Node 20
mise dev # Runs dev server
undefinedcd project
mise install # 安装Node 20
mise dev # 启动开发服务器
undefinedPython Project Setup
Python项目搭建
toml
undefinedtoml
undefined.mise.toml
.mise.toml
[tools]
python = "3.12"
[env]
PYTHONPATH = "{{ config_root }}/src"
[tasks.venv]
run = "python -m venv .venv"
[tasks.install]
run = "pip install -r requirements.txt"
depends = ["venv"]
[tasks.test]
run = "pytest"
depends = ["install"]
[tasks.format]
run = "black src tests"
undefined[tools]
python = "3.12"
[env]
PYTHONPATH = "{{ config_root }}/src"
[tasks.venv]
run = "python -m venv .venv"
[tasks.install]
run = "pip install -r requirements.txt"
depends = ["venv"]
[tasks.test]
run = "pytest"
depends = ["install"]
[tasks.format]
run = "black src tests"
undefinedMonorepo Setup
单体仓库搭建
toml
undefinedtoml
undefinedRoot .mise.toml
根目录.mise.toml
[tools]
node = "20"
python = "3.12"
[env]
WORKSPACE_ROOT = "{{ config_root }}"
[tasks.install-all]
run = """
npm install
cd services/api && npm install
cd services/web && npm install
"""
[tasks.test-all]
depends = ["install-all"]
run = """
mise run test --dir services/api
mise run test --dir services/web
"""
undefined[tools]
node = "20"
python = "3.12"
[env]
WORKSPACE_ROOT = "{{ config_root }}"
[tasks.install-all]
run = """
npm install
cd services/api && npm install
cd services/web && npm install
"""
[tasks.test-all]
depends = ["install-all"]
run = """
mise run test --dir services/api
mise run test --dir services/web
"""
undefinedMulti-Tool Project
多工具项目
toml
undefinedtoml
undefined.mise.toml
.mise.toml
[tools]
node = "20"
python = "3.12"
ruby = "3.3"
go = "1.21"
terraform = "latest"
[env]
PROJECT_ROOT = "{{ config_root }}"
PATH = ["{{ config_root }}/bin", "$PATH"]
[tasks.setup]
description = "Setup all dependencies"
run = """
npm install
pip install -r requirements.txt
bundle install
go mod download
"""
undefined[tools]
node = "20"
python = "3.12"
ruby = "3.3"
go = "1.21"
terraform = "latest"
[env]
PROJECT_ROOT = "{{ config_root }}"
PATH = ["{{ config_root }}/bin", "$PATH"]
[tasks.setup]
description = "搭建所有依赖"
run = """
npm install
pip install -r requirements.txt
bundle install
go mod download
"""
undefinedLock Files
锁定文件
Generate lock files for reproducible environments:
bash
undefined生成锁定文件以确保环境可复现:
bash
undefinedGenerate .mise.lock
生成.mise.lock
mise lock
mise lock
Use locked versions
使用锁定的版本
mise install --locked
```tomlmise install --locked
```toml.mise.toml
.mise.toml
[tools]
node = "20"
[settings]
lockfile = true # Auto-generate lock file
undefined[tools]
node = "20"
[settings]
lockfile = true # 自动生成锁定文件
undefinedShims
垫片(Shims)
Use shims for tool binaries:
bash
undefined使用垫片管理工具二进制文件:
bash
undefinedEnable shims
启用垫片
mise settings set experimental true
mise reshim
mise settings set experimental true
mise reshim
Now tools are in PATH via shims
现在工具通过垫片加入PATH
node --version # Uses mise-managed node
python --version # Uses mise-managed python
undefinednode --version # 使用mise管理的node
python --version # 使用mise管理的python
undefinedConfiguration Locations
配置文件位置
mise reads configuration from multiple locations (in order):
- - Project local config
.mise.toml - - Project local config (alternative)
.mise/config.toml - - Global config
~/.config/mise/config.toml - Environment variables -
MISE_*
mise会从多个位置读取配置(按顺序):
- - 项目本地配置
.mise.toml - - 项目本地配置(替代方案)
.mise/config.toml - - 全局配置
~/.config/mise/config.toml - 环境变量 -
MISE_*
IDE Integration
IDE集成
VS Code
VS Code
Add to :
.vscode/settings.jsonjson
{
"terminal.integrated.env.linux": {
"PATH": "${env:HOME}/.local/share/mise/shims:${env:PATH}"
},
"terminal.integrated.env.osx": {
"PATH": "${env:HOME}/.local/share/mise/shims:${env:PATH}"
}
}添加到:
.vscode/settings.jsonjson
{
"terminal.integrated.env.linux": {
"PATH": "${env:HOME}/.local/share/mise/shims:${env:PATH}"
},
"terminal.integrated.env.osx": {
"PATH": "${env:HOME}/.local/share/mise/shims:${env:PATH}"
}
}JetBrains IDEs
JetBrains IDEs
Use mise shims or configure tool paths:
bash
undefined使用mise垫片或配置工具路径:
bash
undefinedFind tool path
查找工具路径
mise which node
mise which python
undefinedmise which node
mise which python
undefinedCI/CD Integration
CI/CD集成
GitHub Actions
GitHub Actions
yaml
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- name: Run tests
run: mise run testyaml
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: jdx/mise-action@v2
- name: Run tests
run: mise run testGitLab CI
GitLab CI
yaml
test:
image: ubuntu:latest
before_script:
- curl https://mise.run | sh
- eval "$(mise activate bash)"
- mise install
script:
- mise run testyaml
test:
image: ubuntu:latest
before_script:
- curl https://mise.run | sh
- eval "$(mise activate bash)"
- mise install
script:
- mise run testTroubleshooting
故障排除
Check mise status
检查mise状态
bash
undefinedbash
undefinedShow configuration
显示配置
mise config
mise config
Show environment
显示环境
mise env
mise env
Show installed tools
显示已安装的工具
mise list
mise list
Debug mode
调试模式
mise --verbose install node
undefinedmise --verbose install node
undefinedClear cache
清除缓存
bash
undefinedbash
undefinedClear tool cache
清除工具缓存
mise cache clear
mise cache clear
Remove and reinstall
卸载并重新安装
mise uninstall node@20
mise install node@20
undefinedmise uninstall node@20
mise install node@20
undefinedLegacy .tool-versions
兼容旧版.tool-versions
mise is compatible with asdf's :
.tool-versionsundefinedmise兼容asdf的:
.tool-versionsundefined.tool-versions
.tool-versions
nodejs 20.10.0
python 3.12.0
ruby 3.3.0
Convert to mise:
```bashnodejs 20.10.0
python 3.12.0
ruby 3.3.0
转换为mise格式:
```bashmise auto-reads .tool-versions
mise会自动读取.tool-versions
Or convert to .mise.toml
或者转换为.mise.toml
mise config migrate
undefinedmise config migrate
undefinedBest Practices
最佳实践
- Use .mise.toml for projects: Better than .tool-versions (more features)
- Pin versions in projects: Ensure consistency across team
- Use tasks for common operations: Document and standardize workflows
- Lock files in production: Use for reproducibility
mise lock - Global tools for dev: Set global defaults, override per project
- Environment per project: Keep secrets and config in .mise.toml
- Commit .mise.toml: Share config with team
- Don't commit .mise.lock: Let mise generate per environment
- 为项目使用.mise.toml:比.tool-versions功能更丰富
- 在项目中固定版本:确保团队环境一致
- 使用任务处理常见操作:记录并标准化工作流
- 在生产环境使用锁定文件:使用确保可复现性
mise lock - 全局工具用于开发:设置全局默认值,在项目中覆盖
- 为每个项目配置独立环境:将密钥和配置保存在.mise.toml中
- 提交.mise.toml到仓库:与团队共享配置
- 不要提交.mise.lock:让mise在每个环境中生成
Key Principles
核心原则
- Reproducible environments: Lock versions for consistency
- Project-specific config: Each project defines its own tools and env
- Task automation: Centralize common development tasks
- Cross-platform: Same config works on all platforms
- Zero setup for team: Clone and to get started
mise install
- 可复现环境:锁定版本以确保一致性
- 项目特定配置:每个项目定义自己的工具和环境
- 任务自动化:集中管理常见开发任务
- 跨平台支持:相同配置可在所有平台运行
- 团队零配置:克隆仓库后执行即可开始开发
mise install