mise

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

mise - 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
undefined
bash
undefined

macOS/Linux (using curl)

macOS/Linux(使用curl)

macOS (using Homebrew)

macOS(使用Homebrew)

brew install mise
brew install mise

Windows

Windows

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
undefined
echo 'eval "$(mise activate bash)"' >> ~/.bashrc # bash echo 'eval "$(mise activate zsh)"' >> ~/.zshrc # zsh echo 'mise activate fish | source' >> ~/.config/fish/config.fish # fish
undefined

Managing 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
mise ls-remote
before adding to configuration:
bash
undefined
在添加到配置之前,务必使用
mise ls-remote
验证工具名称:
bash
undefined

Check 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>
undefined
mise registry | grep <tool-name>
undefined

Installing Tools

安装工具

bash
undefined
bash
undefined

List 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
undefined
mise install
undefined

Using Tools with
mise use

使用
mise use
管理工具

The
mise use
command is the primary way to add tools to projects. It combines two operations:
  1. Installs the tool (if not already installed)
  2. Adds the tool to your configuration file
Key Difference:
mise install
only installs tools, while
mise use
installs AND configures them.
mise use
命令是向项目添加工具的主要方式,它结合了两个操作:
  1. 安装工具(如果尚未安装)
  2. 添加工具到你的配置文件
关键区别
mise install
仅安装工具,而
mise use
会安装并配置工具。

Basic Usage

基础用法

bash
undefined
bash
undefined

Interactive 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
undefined
mise use cargo:ripgrep@latest mise use ubi:sharkdp/fd
undefined

Configuration File Selection

配置文件选择

mise use
writes to configuration files in this priority order:
  1. --global
    flag
    :
    ~/.config/mise/config.toml
  2. --path <file>
    flag
    : Specified file path
  3. --env <env>
    flag
    :
    .mise.<env>.toml
  4. Default:
    mise.toml
    in current directory
bash
undefined
mise use
会按以下优先级写入配置文件:
  1. --global
    参数
    ~/.config/mise/config.toml
  2. --path <file>
    参数
    :指定的文件路径
  3. --env <env>
    参数
    .mise.<env>.toml
  4. 默认:当前目录下的
    mise.toml
bash
undefined

Global (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
undefined
mise use --path ~/.config/mise/custom.toml node@20
undefined

Important Flags

重要参数

bash
undefined
bash
undefined

Pin 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
undefined
mise use --remove node
undefined

Version Pinning

版本固定

bash
undefined
bash
undefined

Fuzzy (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
mise use
command automatically sets tool versions by updating configuration files.
mise 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" }
undefined
node = { version = "lts", resolve = "latest-lts" }
undefined

UBI 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
undefined
bash
undefined

Install 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"
undefined

UBI 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" }
undefined

UBI 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
templates/
directory contains reusable configuration snippets for common mise patterns.
templates/
目录包含可复用的配置片段,适用于常见的mise使用场景。

Multi-Architecture Tool Installation

多架构工具安装

When installing tools from GitHub releases that provide separate binaries for different platforms/architectures, use platform-specific asset patterns.
See
templates/multi-arch.md
for the pattern:
toml
[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.md
获取模式示例:
toml
[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-x64
    - Linux on x86_64/amd64
  • linux-arm64
    - Linux on ARM64/aarch64
  • macos-x64
    - macOS on Intel (x86_64)
  • macos-arm64
    - macOS on Apple Silicon (M1/M2/M3)
  • windows-x64
    - Windows on x86_64
mise常用的平台标识:
  • linux-x64
    - x86_64/amd64架构的Linux
  • linux-arm64
    - ARM64/aarch64架构的Linux
  • macos-x64
    - Intel(x86_64)架构的macOS
  • macos-arm64
    - Apple Silicon(M1/M2/M3)架构的macOS
  • windows-x64
    - x86_64架构的Windows

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.gz
:
toml
asset_pattern = "beads_*_darwin_arm64.tar.gz"
在资产模式中使用
*
作为通配符,匹配版本号或发布资产名称中的其他可变部分。
例如,对于发布资产类似
beads_1.0.0_darwin_arm64.tar.gz
的工具:
toml
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
undefined

Option 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
undefined
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
undefined

Cargo Usage

Cargo用法

bash
undefined
bash
undefined

Install 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"
undefined

Cargo from Git Repositories

从Git仓库安装Cargo包

bash
undefined
bash
undefined

Specific tag

特定标签

Branch

分支

Commit hash

提交哈希

Cargo 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"
undefined
cargo.registry_name = "my-registry"
undefined

Managing Installed Tools

管理已安装的工具

bash
undefined
bash
undefined

List 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
undefined
mise upgrade node
undefined

Tool Aliases

工具别名

bash
undefined
bash
undefined

Create alias for a tool

为工具创建别名

mise alias node 20 20.10.0
mise alias node 20 20.10.0

Use alias

使用别名

mise use node@20
undefined
mise use node@20
undefined

Environment 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"
undefined
APP_ROOT = "{{ config_root }}" DATA_DIR = "{{ config_root }}/data"
undefined

File-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
undefined
bash
undefined

Use 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)"
undefined
mise set BUILD_ID "$(git rev-parse HEAD)"
undefined

Tasks

任务

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
undefined
bash
undefined

Run 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
undefined
mise run script -- arg1 arg2
undefined

Task 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

undefined
undefined

Task 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 shell
toml
[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/deploy
echo "正在部署..." npm run deploy

设置可执行权限:
```bash
chmod +x .mise/tasks/deploy

Common Workflows

常见工作流

Node.js Project Setup

Node.js项目搭建

toml
undefined
toml
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"]

```bash

Setup and run

搭建并运行

cd project mise install # Installs Node 20 mise dev # Runs dev server
undefined
cd project mise install # 安装Node 20 mise dev # 启动开发服务器
undefined

Python Project Setup

Python项目搭建

toml
undefined
toml
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"
undefined

Monorepo Setup

单体仓库搭建

toml
undefined
toml
undefined

Root .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 """
undefined

Multi-Tool Project

多工具项目

toml
undefined
toml
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 """
undefined

Lock Files

锁定文件

Generate lock files for reproducible environments:
bash
undefined
生成锁定文件以确保环境可复现:
bash
undefined

Generate .mise.lock

生成.mise.lock

mise lock
mise lock

Use locked versions

使用锁定的版本

mise install --locked

```toml
mise install --locked

```toml

.mise.toml

.mise.toml

[tools] node = "20"
[settings] lockfile = true # Auto-generate lock file
undefined
[tools] node = "20"
[settings] lockfile = true # 自动生成锁定文件
undefined

Shims

垫片(Shims)

Use shims for tool binaries:
bash
undefined
使用垫片管理工具二进制文件:
bash
undefined

Enable 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
undefined
node --version # 使用mise管理的node python --version # 使用mise管理的python
undefined

Configuration Locations

配置文件位置

mise reads configuration from multiple locations (in order):
  1. .mise.toml
    - Project local config
  2. .mise/config.toml
    - Project local config (alternative)
  3. ~/.config/mise/config.toml
    - Global config
  4. Environment variables -
    MISE_*
mise会从多个位置读取配置(按顺序):
  1. .mise.toml
    - 项目本地配置
  2. .mise/config.toml
    - 项目本地配置(替代方案)
  3. ~/.config/mise/config.toml
    - 全局配置
  4. 环境变量 -
    MISE_*

IDE Integration

IDE集成

VS Code

VS Code

Add to
.vscode/settings.json
:
json
{
  "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.json
json
{
  "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
undefined

Find tool path

查找工具路径

mise which node mise which python
undefined
mise which node mise which python
undefined

CI/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 test
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 test

GitLab CI

GitLab CI

yaml
test:
  image: ubuntu:latest
  before_script:
    - curl https://mise.run | sh
    - eval "$(mise activate bash)"
    - mise install
  script:
    - mise run test
yaml
test:
  image: ubuntu:latest
  before_script:
    - curl https://mise.run | sh
    - eval "$(mise activate bash)"
    - mise install
  script:
    - mise run test

Troubleshooting

故障排除

Check mise status

检查mise状态

bash
undefined
bash
undefined

Show configuration

显示配置

mise config
mise config

Show environment

显示环境

mise env
mise env

Show installed tools

显示已安装的工具

mise list
mise list

Debug mode

调试模式

mise --verbose install node
undefined
mise --verbose install node
undefined

Clear cache

清除缓存

bash
undefined
bash
undefined

Clear tool cache

清除工具缓存

mise cache clear
mise cache clear

Remove and reinstall

卸载并重新安装

mise uninstall node@20 mise install node@20
undefined
mise uninstall node@20 mise install node@20
undefined

Legacy .tool-versions

兼容旧版.tool-versions

mise is compatible with asdf's
.tool-versions
:
undefined
mise兼容asdf的
.tool-versions
undefined

.tool-versions

.tool-versions

nodejs 20.10.0 python 3.12.0 ruby 3.3.0

Convert to mise:

```bash
nodejs 20.10.0 python 3.12.0 ruby 3.3.0

转换为mise格式:

```bash

mise auto-reads .tool-versions

mise会自动读取.tool-versions

Or convert to .mise.toml

或者转换为.mise.toml

mise config migrate
undefined
mise config migrate
undefined

Best 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
    mise lock
    for reproducibility
  • 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
    mise install
    to get started
  • 可复现环境:锁定版本以确保一致性
  • 项目特定配置:每个项目定义自己的工具和环境
  • 任务自动化:集中管理常见开发任务
  • 跨平台支持:相同配置可在所有平台运行
  • 团队零配置:克隆仓库后执行
    mise install
    即可开始开发