mise-tool-management

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Mise - Tool Management

Mise - 工具版本管理

Managing development tool versions across projects with Mise as a unified version manager.
使用Mise作为统一的版本管理器,跨项目管理开发工具版本。

Basic Tool Installation

基础工具安装

Installing Tools

安装工具

bash
undefined
bash
undefined

Install specific version

Install specific version

mise install node@20.10.0 mise install python@3.12.0 mise install rust@1.75.0
mise install node@20.10.0 mise install python@3.12.0 mise install rust@1.75.0

Install latest version

Install latest version

mise install node@latest mise install python@latest
mise install node@latest mise install python@latest

Install from .tool-versions or mise.toml

Install from .tool-versions or mise.toml

mise install
undefined
mise install
undefined

Setting Tool Versions

设置工具版本

bash
undefined
bash
undefined

Set global version

Set global version

mise use --global node@20
mise use --global node@20

Set project version

Set project version

mise use node@20.10.0 mise use python@3.12 rust@1.75
mise use node@20.10.0 mise use python@3.12 rust@1.75

Use latest

Use latest

mise use node@latest
undefined
mise use node@latest
undefined

Tool Configuration in mise.toml

mise.toml中的工具配置

Basic Tool Definitions

基础工具定义

toml
undefined
toml
undefined

mise.toml

mise.toml

[tools] node = "20.10.0" python = "3.12.0" rust = "1.75.0" terraform = "1.6.0"
undefined
[tools] node = "20.10.0" python = "3.12.0" rust = "1.75.0" terraform = "1.6.0"
undefined

Version Prefixes

版本前缀

toml
[tools]
toml
[tools]

Latest patch version

Latest patch version

node = "20.10"
node = "20.10"

Latest minor version

Latest minor version

node = "20"
node = "20"

Latest version

Latest version

node = "latest"
node = "latest"

Prefix notation

Prefix notation

terraform = "1.6" # Latest 1.6.x
undefined
terraform = "1.6" # Latest 1.6.x
undefined

Multiple Versions

多版本配置

toml
[tools]
toml
[tools]

Use multiple versions

Use multiple versions

node = ["20.10.0", "18.19.0"] python = ["3.12", "3.11", "3.10"]

```bash
node = ["20.10.0", "18.19.0"] python = ["3.12", "3.11", "3.10"]

```bash

Switch between versions

Switch between versions

mise shell node@18.19.0
undefined
mise shell node@18.19.0
undefined

Tool-Specific Configuration

工具专属配置

Node.js Configuration

Node.js配置

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

Python with Virtual Environments

搭配虚拟环境的Python配置

toml
[tools]
python = "3.12"

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

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

Custom Tool Sources

自定义工具源

toml
[tools]
toml
[tools]

From specific registry

From specific registry

"cargo:eza" = "latest" "npm:typescript" = "5.3"
"cargo:eza" = "latest" "npm:typescript" = "5.3"

From git repository

From git repository

undefined
undefined

Supported Languages & Tools

支持的语言与工具

Core Tools

核心工具

toml
[tools]
toml
[tools]

Languages

Languages

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

Infrastructure

Infrastructure

terraform = "1.6" kubectl = "1.28" awscli = "2.13"
undefined
terraform = "1.6" kubectl = "1.28" awscli = "2.13"
undefined

Package Managers

包管理器

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

Tool Version Strategies

工具版本策略

Lock to Specific Versions

锁定到特定版本

toml
undefined
toml
undefined

Production: Pin exact versions

Production: Pin exact versions

[tools] node = "20.10.0" terraform = "1.6.4"
undefined
[tools] node = "20.10.0" terraform = "1.6.4"
undefined

Use Ranges for Flexibility

使用版本范围提升灵活性

toml
undefined
toml
undefined

Development: Use minor version ranges

Development: Use minor version ranges

[tools] node = "20" # Any 20.x python = "3.12" # Any 3.12.x
undefined
[tools] node = "20" # Any 20.x python = "3.12" # Any 3.12.x
undefined

Latest for Experimentation

使用最新版本进行实验

toml
undefined
toml
undefined

Experimental projects

Experimental projects

[tools] rust = "latest" bun = "latest"
undefined
[tools] rust = "latest" bun = "latest"
undefined

Managing Tool Aliases

管理工具别名

Creating Aliases

创建别名

bash
undefined
bash
undefined

Set alias for current directory

Set alias for current directory

mise alias set node lts 20.10.0
mise alias set node lts 20.10.0

Set global alias

Set global alias

mise alias set --global python3 python@3.12
undefined
mise alias set --global python3 python@3.12
undefined

Using Aliases in Configuration

在配置中使用别名

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

Tool Verification

工具验证

Check Installed Tools

检查已安装工具

bash
undefined
bash
undefined

List installed tools

List installed tools

mise list
mise list

Check current versions

Check current versions

mise current
mise current

Verify tool installation

Verify tool installation

mise doctor
undefined
mise doctor
undefined

Tool Information

工具信息查询

bash
undefined
bash
undefined

Show tool details

Show tool details

mise ls-remote node
mise ls-remote node

List available versions

List available versions

mise ls-remote python
mise ls-remote python

Check latest version

Check latest version

mise latest node
undefined
mise latest node
undefined

Migration from Other Version Managers

从其他版本管理器迁移

From asdf

从asdf迁移

bash
undefined
bash
undefined

Mise reads .tool-versions files

Mise reads .tool-versions files

cat .tool-versions
cat .tool-versions

nodejs 20.10.0

nodejs 20.10.0

python 3.12.0

python 3.12.0

Migrate to mise.toml

Migrate to mise.toml

mise use node@20.10.0 python@3.12.0
undefined
mise use node@20.10.0 python@3.12.0
undefined

From nvm

从nvm迁移

bash
undefined
bash
undefined

Read from .nvmrc

Read from .nvmrc

cat .nvmrc
cat .nvmrc

20.10.0

20.10.0

mise use node@$(cat .nvmrc)
undefined
mise use node@$(cat .nvmrc)
undefined

From pyenv

从pyenv迁移

bash
undefined
bash
undefined

Read from .python-version

Read from .python-version

mise use python@$(cat .python-version)
undefined
mise use python@$(cat .python-version)
undefined

Best Practices

最佳实践

Pin Production Dependencies

固定生产环境依赖版本

toml
undefined
toml
undefined

Good: Explicit production versions

Good: Explicit production versions

[tools] node = "20.10.0" terraform = "1.6.4" postgres = "16.1"
undefined
[tools] node = "20.10.0" terraform = "1.6.4" postgres = "16.1"
undefined

Document Required Tools

记录所需工具

toml
undefined
toml
undefined

mise.toml - All project dependencies in one place

mise.toml - All project dependencies in one place

[tools] node = "20.10.0" python = "3.12.0" terraform = "1.6.4" kubectl = "1.28.0"
[env] PROJECT_NAME = "my-app"
undefined
[tools] node = "20.10.0" python = "3.12.0" terraform = "1.6.4" kubectl = "1.28.0"
[env] PROJECT_NAME = "my-app"
undefined

Use Tool-Specific Settings

使用工具专属设置

toml
[tools]
toml
[tools]

Enable corepack for package managers

Enable corepack for package managers

node = { version = "20.10.0", postinstall = "corepack enable" }
node = { version = "20.10.0", postinstall = "corepack enable" }

Create Python virtual environment

Create Python virtual environment

python = { version = "3.12", venv = ".venv" }
undefined
python = { version = "3.12", venv = ".venv" }
undefined

Verify Tool Installation

验证工具安装

bash
undefined
bash
undefined

In CI/CD pipelines

In CI/CD pipelines

mise install --check mise doctor
mise install --check mise doctor

Verify specific tools

Verify specific tools

mise current node mise current python
undefined
mise current node mise current python
undefined

Common Patterns

常见模式

Monorepo Tool Management

单体仓库工具管理

toml
undefined
toml
undefined

Root mise.toml - shared tools

Root mise.toml - shared tools

[tools] node = "20.10.0" terraform = "1.6.4"
[tools] node = "20.10.0" terraform = "1.6.4"

packages/api/mise.toml - additional tools

packages/api/mise.toml - additional tools

[tools] "npm:typescript" = "5.3" "npm:prisma" = "5.7"
[tools] "npm:typescript" = "5.3" "npm:prisma" = "5.7"

packages/web/mise.toml

packages/web/mise.toml

[tools] "npm:next" = "14.0"
undefined
[tools] "npm:next" = "14.0"
undefined

Development vs Production

开发环境与生产环境区分

toml
undefined
toml
undefined

mise.toml - production tools

mise.toml - production tools

[tools] node = "20.10.0" postgres = "16.1"
[tools] node = "20.10.0" postgres = "16.1"

mise.local.toml - development tools (gitignored)

mise.local.toml - development tools (gitignored)

[tools] "npm:nodemon" = "latest" "cargo:cargo-watch" = "latest"
undefined
[tools] "npm:nodemon" = "latest" "cargo:cargo-watch" = "latest"
undefined

Tool Updates Strategy

工具更新策略

bash
undefined
bash
undefined

Check for updates

Check for updates

mise outdated
mise outdated

Update to latest patch version

Update to latest patch version

mise upgrade node
mise upgrade node

Update all tools

Update all tools

mise upgrade
mise upgrade

Update with constraints

Update with constraints

mise use node@20 # Updates to latest 20.x
undefined
mise use node@20 # Updates to latest 20.x
undefined

Anti-Patterns

反模式

Don't Mix Version Managers

不要混用多个版本管理器

bash
undefined
bash
undefined

Bad: Using multiple version managers

Bad: Using multiple version managers

nvm use 20 mise use node@20 # Conflicts
nvm use 20 mise use node@20 # Conflicts

Good: Use only Mise

Good: Use only Mise

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

Don't Hardcode Tool Paths

不要硬编码工具路径

bash
undefined
bash
undefined

Bad: Hardcoded paths

Bad: Hardcoded paths

/Users/me/.local/share/mise/installs/node/20.10.0/bin/node
/Users/me/.local/share/mise/installs/node/20.10.0/bin/node

Good: Use mise shims or mise exec

Good: Use mise shims or mise exec

mise exec -- node mise x -- node
undefined
mise exec -- node mise x -- node
undefined

Don't Skip Version Constraints

不要跳过版本约束

toml
undefined
toml
undefined

Bad: No version specified

Bad: No version specified

[tools] node = "latest" # Can break on updates
[tools] node = "latest" # Can break on updates

Good: Specify constraints

Good: Specify constraints

[tools] node = "20.10.0" # Explicit
[tools] node = "20.10.0" # Explicit

OR

OR

node = "20" # Controlled range
undefined
node = "20" # Controlled range
undefined

Don't Ignore Tool Dependencies

不要忽略工具依赖

toml
undefined
toml
undefined

Bad: Missing required tools

Bad: Missing required tools

[tools] terraform = "1.6"
[tools] terraform = "1.6"

Missing: kubectl, helm for deployment

Missing: kubectl, helm for deployment

Good: Include all dependencies

Good: Include all dependencies

[tools] terraform = "1.6.4" kubectl = "1.28.0" helm = "3.13.0"
undefined
[tools] terraform = "1.6.4" kubectl = "1.28.0" helm = "3.13.0"
undefined

Advanced Patterns

进阶模式

Conditional Tool Installation

条件化工具安装

toml
[tools]
toml
[tools]

Install based on platform

Install based on platform

node = "20.10.0" python = "3.12"
node = "20.10.0" python = "3.12"

Platform-specific tools

Platform-specific tools

[tools."cargo:watchexec-cli"] platforms = ["linux", "darwin"] version = "latest"
undefined
[tools."cargo:watchexec-cli"] platforms = ["linux", "darwin"] version = "latest"
undefined

Tool Installation Hooks

工具安装钩子

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

Backend Selection

后端选择

toml
undefined
toml
undefined

Use specific backend for tools

Use specific backend for tools

[tools]
[tools]

Use core backend (faster)

Use core backend (faster)

node = "core:20.10.0"
node = "core:20.10.0"

Use asdf plugin

Use asdf plugin

ruby = "asdf:3.3.0"
undefined
ruby = "asdf:3.3.0"
undefined

Related Skills

相关技能

  • task-configuration: Defining tasks that use managed tools
  • environment-management: Managing environment variables with tools
  • task-configuration: 定义使用已管理工具的任务
  • environment-management: 结合工具管理环境变量