proto

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

proto - Pluggable Multi-Language Version Manager

proto - 可插拔式多语言版本管理器

proto is a next-generation version manager for multiple programming languages. It provides a unified interface for managing Node.js, npm, pnpm, yarn, Bun, Deno, Rust, Go, Python, and 800+ tools via plugins.
proto是一款面向多种编程语言的下一代版本管理器。它提供统一的界面,可通过插件管理Node.js、npm、pnpm、yarn、Bun、Deno、Rust、Go、Python以及800+种工具。

When to Use proto

适用场景

  • Managing language/tool versions across projects
  • Pinning versions in
    .prototools
    for team consistency
  • Installing and running tools without global pollution
  • Replacing nvm, pyenv, rustup, gvm with a single tool
  • 跨项目管理语言/工具版本
  • 在.prototools中固定版本,保证团队一致性
  • 安装并运行工具,避免全局环境污染
  • 用单个工具替代nvm、pyenv、rustup、gvm

Installation

安装

bash
undefined
bash
undefined

Linux, macOS, WSL

Linux、macOS、WSL

Specific version, non-interactive

指定版本,非交互式安装

bash <(curl -fsSL https://moonrepo.dev/install/proto.sh) 1.2.3 --yes
undefined
bash <(curl -fsSL https://moonrepo.dev/install/proto.sh) 1.2.3 --yes
undefined

Shell Setup

Shell 配置

bash
undefined
bash
undefined

Add to shell profile

添加到Shell配置文件

eval "$(proto activate bash)" # Bash eval "$(proto activate zsh)" # Zsh
undefined
eval "$(proto activate bash)" # Bash eval "$(proto activate zsh)" # Zsh
undefined

Quick Reference

快速参考

Core Commands

核心命令

bash
proto install <tool>           # Install tool
proto install node 20.10.0     # Install specific version
proto install node --build     # Build from source (v0.45+)
proto run <tool>               # Run with detected version
proto exec node pnpm -- cmd    # Bootstrap multi-tool env (v0.53+)
proto pin <tool> <version>     # Pin version locally
proto pin <tool> --global      # Pin globally
proto versions <tool>          # List available versions
proto outdated                 # Check for updates
proto clean                    # Remove unused tools
proto upgrade                  # Upgrade proto itself
proto diagnose                 # Identify installation issues
proto debug config             # List all .prototools files
proto debug env                # Show environment info
bash
proto install <tool>           # 安装工具
proto install node 20.10.0     # 安装指定版本
proto install node --build     # 从源码构建(v0.45+)
proto run <tool>               # 使用检测到的版本运行工具
proto exec node pnpm -- cmd    # 引导多工具环境(v0.53+)
proto pin <tool> <version>     # 在本地固定版本
proto pin <tool> --global      # 全局固定版本
proto versions <tool>          # 列出可用版本
proto outdated                 # 检查更新
proto clean                    # 移除未使用的工具
proto upgrade                  # 升级proto本身
proto diagnose                 # 排查安装问题
proto debug config             # 列出所有.prototools文件
proto debug env                # 显示环境信息

Configuration: .prototools

配置:.prototools

toml
undefined
toml
undefined

.prototools

.prototools

node = "20.10.0" npm = "10.2.0" pnpm = "8.12.0" yarn = "4.0.0" bun = "1.0.0" deno = "1.40.0" rust = "1.75.0" go = "1.21.0" python = "3.12.0"
[plugins] my-tool = "https://example.com/plugin.wasm"
[settings] auto-install = true auto-clean = true detect-strategy = "prefer-prototools"
[env] NODE_ENV = "development"
undefined
node = "20.10.0" npm = "10.2.0" pnpm = "8.12.0" yarn = "4.0.0" bun = "1.0.0" deno = "1.40.0" rust = "1.75.0" go = "1.21.0" python = "3.12.0"
[plugins] my-tool = "https://example.com/plugin.wasm"
[settings] auto-install = true auto-clean = true detect-strategy = "prefer-prototools"
[env] NODE_ENV = "development"
undefined

Version Specifiers

版本指定格式

FormatExampleDescription
Exact
"20.10.0"
Exact version
Major
"20"
Latest 20.x.x
Tilde
"~20.10"
Patch updates only
Alias
"stable"
Language-specific alias
格式示例说明
精确版本
"20.10.0"
完全匹配的版本
大版本
"20"
最新的20.x.x版本
波浪号
"~20.10"
仅更新补丁版本
别名
"stable"
语言特定的别名

Supported Tools (Built-in)

支持的内置工具

JavaScript/TypeScript

JavaScript/TypeScript

bash
proto install node     # Node.js runtime
proto install npm      # npm package manager
proto install pnpm     # pnpm package manager
proto install yarn     # Yarn package manager
proto install bun      # Bun runtime
proto install deno     # Deno runtime
bash
proto install node     # Node.js 运行时
proto install npm      # npm 包管理器
proto install pnpm     # pnpm 包管理器
proto install yarn     # Yarn 包管理器
proto install bun      # Bun 运行时
proto install deno     # Deno 运行时

Systems Languages

系统级语言

bash
proto install rust     # Rust (includes cargo)
proto install go       # Go
bash
proto install rust     # Rust(包含cargo)
proto install go       # Go

Other

其他

bash
proto install python   # Python (includes pip)
bash
proto install python   # Python(包含pip)

Version Detection Order

版本检测顺序

  1. CLI argument:
    proto run node 18.0.0
  2. Environment variable:
    PROTO_NODE_VERSION=18.0.0
  3. Local
    .prototools
    (current + parent dirs)
  4. Ecosystem files:
    .nvmrc
    ,
    .node-version
    ,
    package.json
    engines
  5. Global
    .prototools
    :
    ~/.proto/.prototools
  1. 命令行参数:
    proto run node 18.0.0
  2. 环境变量:
    PROTO_NODE_VERSION=18.0.0
  3. 本地.prototools文件(当前目录及父目录)
  4. 生态系统文件:
    .nvmrc
    .node-version
    package.json
    中的engines字段
  5. 全局.prototools文件:
    ~/.proto/.prototools

Common Workflows

常见工作流

Pin Versions for Team

为团队固定版本

bash
undefined
bash
undefined

Pin to local .prototools

固定到本地.prototools

proto pin node 20.10.0 proto pin pnpm 8.12.0
proto pin node 20.10.0 proto pin pnpm 8.12.0

Pin globally (user default)

全局固定(用户默认版本)

proto pin node 20 --global
undefined
proto pin node 20 --global
undefined

Install All Tools

安装所有工具

bash
undefined
bash
undefined

Install everything from .prototools

安装.prototools中配置的所有工具

proto install
undefined
proto install
undefined

Check for Updates

检查更新

bash
proto outdated                    # Check for updates
proto outdated --update --latest  # Update .prototools
bash
proto outdated                    # 检查可用更新
proto outdated --update --latest  # 更新.prototools中的版本

Run with Specific Version

使用指定版本运行

bash
proto run node 18 -- script.js    # Override version
PROTO_NODE_VERSION=18 proto run node  # Via env var
bash
proto run node 18 -- script.js    # 覆盖默认版本
PROTO_NODE_VERSION=18 proto run node  # 通过环境变量指定

Proto Exec (v0.53+)

Proto Exec(v0.53+)

Bootstrap an environment with multiple tools:
bash
undefined
引导包含多个工具的环境:
bash
undefined

Run command with multiple tools

使用多个工具运行命令

proto exec node@24 pnpm@10 ruby@3.4 -- pnpm run app:start
proto exec node@24 pnpm@10 ruby@3.4 -- pnpm run app:start

Load tools from config

从配置文件加载工具

proto exec --tools-from-config -- npm test
proto exec --tools-from-config -- npm test

Interactive shell with activated tools

进入包含已激活工具的交互式Shell

proto exec node pnpm -- bash
undefined
proto exec node pnpm -- bash
undefined

Build From Source (v0.45+)

从源码构建(v0.45+)

Compile tools from source (useful when pre-built binaries unavailable):
bash
proto install ruby --build
proto install node --build
proto install python --build
Supported: Deno, Go, Moon, Node, Python, Ruby.
toml
undefined
从源码编译工具(当预构建二进制文件不可用时适用):
bash
proto install ruby --build
proto install node --build
proto install python --build
支持的工具:Deno、Go、Moon、Node、Python、Ruby。
toml
undefined

.prototools

.prototools

[settings.build] install-system-packages = true write-log-file = true
undefined
[settings.build] install-system-packages = true write-log-file = true
undefined

Plugins

插件

Add Third-Party Plugin

添加第三方插件

bash
proto plugin add atlas "https://raw.githubusercontent.com/.../plugin.toml"
proto install atlas
bash
proto plugin add atlas "https://raw.githubusercontent.com/.../plugin.toml"
proto install atlas

List Plugins

列出插件

bash
proto plugin list           # Show all plugins
proto plugin list --versions  # With version info
bash
proto plugin list           # 显示所有插件
proto plugin list --versions  # 包含版本信息

Plugin Sources

插件来源

toml
[plugins]
toml
[plugins]

Remote TOML plugin

远程TOML插件

Remote WASM plugin

远程WASM插件

GitHub releases (recommended for distribution)

GitHub Releases(推荐的分发方式)

my-tool = "github://org/repo"
my-tool = "github://org/repo"

Local development (WASM)

本地开发(WASM)

local = "file://./target/wasm32-wasip1/release/plugin.wasm"
undefined
local = "file://./target/wasm32-wasip1/release/plugin.wasm"
undefined

WASM Plugin Development

WASM插件开发

Build plugins with
proto_pdk
crate targeting
wasm32-wasip1
:
bash
undefined
使用
proto_pdk
crate构建目标为
wasm32-wasip1
的插件:
bash
undefined

Build plugin

构建插件

cargo build --target wasm32-wasip1 --release
cargo build --target wasm32-wasip1 --release

Test locally

本地测试

proto install my-tool --log trace

Test configuration for local development:

```toml
proto install my-tool --log trace

本地开发测试配置:

```toml

.prototools

.prototools

[settings] unstable-lockfile = true # Create .protolock for consistency
[plugins.tools] my-tool = "file://./target/wasm32-wasip1/release/my_tool.wasm"

Required WASM functions:

- `register_tool` - Metadata (name, type)
- `download_prebuilt` - Configure download/install
- `locate_executables` - Define executable paths
- `load_versions` - Fetch available versions

Optional: `native_install`, `detect_version_files`, `parse_version_file`
[settings] unstable-lockfile = true # 创建.protolock以保证一致性
[plugins.tools] my-tool = "file://./target/wasm32-wasip1/release/my_tool.wasm"

必备WASM函数:

- `register_tool` - 元数据(名称、类型)
- `download_prebuilt` - 配置下载/安装逻辑
- `locate_executables` - 定义可执行文件路径
- `load_versions` - 获取可用版本列表

可选函数:`native_install`, `detect_version_files`, `parse_version_file`

Settings

设置项

toml
[settings]
toml
[settings]

Auto-install missing tools

自动安装缺失的工具

auto-install = true
auto-install = true

Auto-clean unused tools

自动清理未使用的工具

auto-clean = true
auto-clean = true

Version detection strategy

版本检测策略

first-available, prefer-prototools, only-prototools

first-available, prefer-prototools, only-prototools

detect-strategy = "prefer-prototools"
detect-strategy = "prefer-prototools"

Pin "latest" alias to local or global config

将"latest"别名固定到本地或全局配置

pin-latest = "local"
pin-latest = "local"

Create .protolock for reproducible installs

创建.protolock以实现可复现的安装

unstable-lockfile = true
unstable-lockfile = true

Disable telemetry

禁用遥测

telemetry = false
[settings.http]
telemetry = false
[settings.http]

Configure proxies

配置代理

proxies = ["https://internal.proxy"] root-cert = "/path/to/cert.pem"
[settings.offline] timeout = 500 # ms
undefined
proxies = ["https://internal.proxy"] root-cert = "/path/to/cert.pem"
[settings.offline] timeout = 500 # 毫秒
undefined

Environment Variables

环境变量

VariableDescription
PROTO_HOME
Installation directory (default:
~/.proto
)
PROTO_LOG
Log level (trace, debug, info, warn, error)
PROTO_*_VERSION
Override version for tool
PROTO_ENV
Environment for config lookup
PROTO_BYPASS_VERSION_CHECK
Skip version validation
变量说明
PROTO_HOME
安装目录(默认:
~/.proto
PROTO_LOG
日志级别(trace, debug, info, warn, error)
PROTO_*_VERSION
覆盖指定工具的版本
PROTO_ENV
配置查找的环境上下文
PROTO_BYPASS_VERSION_CHECK
跳过版本验证

Development/Testing Variables

开发/测试变量

VariableDescription
PROTO_TEST
Enable test mode (loads test plugins)
PROTO_DEBUG_COMMAND
Show detailed command execution
PROTO_DEBUG_WASM
Enable WASM plugin debugging
WASMTIME_BACKTRACE_DETAILS
Detailed WASM backtraces
变量说明
PROTO_TEST
启用测试模式(加载测试插件)
PROTO_DEBUG_COMMAND
显示详细的命令执行日志
PROTO_DEBUG_WASM
启用WASM插件调试
WASMTIME_BACKTRACE_DETAILS
显示详细的WASM调用栈

Integration with moon

与moon集成

proto is the toolchain backend for moon. Configure in
.moon/toolchains.yml
(v2):
yaml
undefined
proto是moon的工具链后端。在
.moon/toolchains.yml
(v2版本)中配置:
yaml
undefined

.moon/toolchains.yml

.moon/toolchains.yml

javascript: packageManager: "pnpm"
node: version: "20.10.0"

Or pin moon itself via proto:

```toml
javascript: packageManager: "pnpm"
node: version: "20.10.0"

也可以通过proto固定moon本身的版本:

```toml

.prototools

.prototools

moon = "1.31.0"
undefined
moon = "1.31.0"
undefined

CI/CD Integration

CI/CD集成

yaml
undefined
yaml
undefined

GitHub Actions

GitHub Actions

  • uses: moonrepo/setup-toolchain@v0 with: auto-install: true
undefined
  • uses: moonrepo/setup-toolchain@v0 with: auto-install: true
undefined

Additional Resources

更多资源

For detailed configuration, consult:
  • references/config.md
    - Complete .prototools reference
  • references/plugins.md
    - Plugin development guide
  • references/commands.md
    - Full CLI reference
如需详细配置说明,请参考:
  • references/config.md
    - 完整的.prototools参考文档
  • references/plugins.md
    - 插件开发指南
  • references/commands.md
    - 完整的CLI参考文档

Examples

示例

  • examples/prototools-full.toml
    - Complete configuration
  • examples/plugin.toml
    - TOML plugin example
  • examples/prototools-full.toml
    - 完整配置示例
  • examples/plugin.toml
    - TOML插件示例