# Just（命令运行器）

**Just** 是一个命令运行器，它将名为配方的命名命令存储在名为 `justfile` 的文件中，其语法受 `make` 启发，并在以 `just RECIPE` 调用时运行它们<sup>[1](https://just.systems/man/en/introduction.html)</sup>。它由凯西·罗达莫（Casey Rodarmor）用 Rust 编写，以单个二进制文件分发，在 Linux、macOS、Windows 和其他 Unix 系统上无运行时依赖，并以知识共享零（CC0）1.0 版许可<sup>[2](https://casey.github.io/blog/just-hack/)</sup><sup> • </sup><sup>[3](https://vo.rs/story/just-and-task-modern-alternatives-to-make-that-dont-make-you-cry/)</sup><sup> • </sup><sup>[4](https://lwn.net/Articles/1047715/)</sup>。该项目将自己描述为命令运行器，而非构建系统，并刻意省略了定义 Make 这类工具的文件时间戳跟踪<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。

| 关键事实 | 详情 |
|---|---|
| 它是什么 | 一个将配方存储在 `justfile` 中的命令运行器；所有配方都被视为伪目标，因此无需 `.PHONY` 声明<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup> |
| 语言与许可证 | 用 Rust 编写；CC0-1.0 许可证；仓库创建于 2016-06-17<sup>[2](https://casey.github.io/blog/just-hack/)</sup><sup> • </sup><sup>[6](https://crates.io/crates/just)</sup><sup> • </sup><sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup> |
| 变更检测 | 默认没有通用的基于文件的变更检测：没有文件依赖图；不稳定的 `[cache]` 属性可以跳过未变化的工作<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup> |
| 并行性 | 通过 `[parallel]` 属性选择加入，且作用域限于配方；同时运行的配方数量可用 `--jobs` 限制，该选项在 1.56.0 中加入<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup> |
| 默认 shell | `sh -cu`；在 Windows 上，默认使用 `sh`，可通过 `[windows]` 属性更改<sup>[1](https://just.systems/man/en/introduction.html)</sup> |
| 采用情况 | crates.io 上总下载量 2,779,610 次（版本 1.58.0）；365 天内 Homebrew 安装量 417,985 次<sup>[6](https://crates.io/crates/just)</sup><sup> • </sup><sup>[8](https://formulae.brew.sh/formula/just)</sup> |
| 稳定性承诺 | 手册声明永远不会出现 Just 2.0；向后不兼容的更改将按 justfile 选择加入<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup> |

## 设计哲学：命令运行器，而非构建系统

Just 最初是一个名为 `j` 的工具，封装了 `make`。其作者在仓库中开启第 1 号议题，计划移除对 make 的依赖，转而采用专用文件格式，并列出促使其分离的 make 行为：Make 的配方语法传统上要求前导制表符；如果存在同名文件，make 将不会运行配方，需要 `.PHONY` 指令作为变通；并且 make 配方某一行的导出变量在后续行中不可用<sup>[9](https://github.com/casey/just/issues/1)</sup>。

核心设计决策是对目标的处理。在 makefile 中，目标可以是文件名，因此当文件存在且其依赖项已是最新时，make 会跳过配方。Just 将所有目标设为静态目标，不尝试判断它们是否最新<sup>[10](https://spin.atomicobject.com/just-task-runner/)</sup>。用手册的话说，所有配方都被当作伪目标处理<sup>[11](https://just.systems/man/en/what-are-the-idiosyncrasies-of-make-that-just-avoids.html)</sup>。这移除了文件先决条件模型：没有通用的基于文件的时间戳或哈希跟踪，没有文件依赖图（只有配方依赖），没有通用产物缓存，也没有包依赖解析<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup>。将依赖时间戳的 Makefile 迁移到 Just 会导致每次都重新构建，而项目将此视为设计而非缺陷<sup>[3](https://vo.rs/story/just-and-task-modern-alternatives-to-make-that-dont-make-you-cry/)</sup>。

放弃变更检测换来了其他方面的简洁。只要可能，错误都会静态解决：未知配方和循环依赖会在任何内容运行之前报告<sup>[1](https://just.systems/man/en/introduction.html)</sup>。Just 还避免了 make 的其他怪癖，包括赋值中 `=` 与 `:=` 的区别、令人困惑的 makefile 错误消息、在配方中使用环境变量需要 `$$`，以及不同 make 变体之间的不兼容<sup>[11](https://just.systems/man/en/what-are-the-idiosyncrasies-of-make-that-just-avoids.html)</sup>。

命令运行器与构建系统的区别在实践中很重要。Make 可被视为既是构建工具又是任务运行器，而 Just 仅是任务运行器<sup>[10](https://spin.atomicobject.com/just-task-runner/)</sup>。评论者将该项目描述为受 Make 语法启发，但不是完整的构建系统，它通过将构建委托给特定语言的工具来降低复杂性<sup>[12](https://www.clientserver.dev/p/the-human-urge-to-replace-makefiles)</sup>。一项关于 monorepo 工具的调研将 Just 归类为典型的无变更检测的最小命令运行器，比增加指纹识别的 Task 低一档<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup>。

## Justfile 语法与特性

配方可以接受命令行参数，包括标志和选项，并可用任意语言编写，例如 Python 或 Node.js<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。参数是一等公民，而非难以传递；配方通过 `just --list` 展示自身的说明文档<sup>[13](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)</sup>。Just 还加载 `.env` 文件，并为大多数流行 shell 提供 shell 补全脚本<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。

**shell 选择。** `shell` 设置控制用于调用配方行和反引号的命令；shebang 配方不受影响。默认 shell 是 `sh -cu`<sup>[1](https://just.systems/man/en/introduction.html)</sup>。在 Windows 上，Just 默认使用 `sh`，可通过 `shell` 设置上的 `[windows]` 属性选择不同的 shell<sup>[1](https://just.systems/man/en/introduction.html)</sup>。

**组织。** Justfile 可以使用模块和导入组织到多个文件中<sup>[1](https://just.systems/man/en/introduction.html)</sup>。monorepo 可以建模为声明 `mod` 子模块的根 justfile，从而为大型仓库提供命名的、有文档的、参数化的配方，每个配方有自己的工作目录，以及命名空间树<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup>。

## 与 Make、Task 和 npm 脚本的比较

与 Make 相比，在命令运行用途上对比最为鲜明。Make 作为命令运行器的难用之处包括：强制使用制表符；默认情况下，每个配方行在单独的 shell 中运行；令人意外的变量展开；尴尬的参数传递；以及需要声明 `.PHONY`，否则名为 `test` 的文件会悄悄禁用 `test` 目标<sup>[13](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)</sup>。Just 保留了 Make 熟悉的语法，但去掉了构建系统语义<sup>[13](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)</sup>。Just 的配方可以依赖其他配方，依赖会无条件执行；它没有也不检查文件依赖<sup>[14](https://appliedgo.net/spotlight/just-make-a-task/)</sup>。

与 Task 相比，差异在于格式和变更检测。Task 用 Go 编写，以单个静态二进制文件分发，理解输入和输出以跳过未变化的工作，并在 `--` 分隔符后通过 `{{.CLI_ARGS}}` 转发额外参数（`task deploy -- staging`），而 Just 直接传递命名参数，如 `just deploy staging`<sup>[3](https://vo.rs/story/just-and-task-modern-alternatives-to-make-that-dont-make-you-cry/)</sup>。Task 用 YAML 编写，通过嵌入可执行文件本身的 shell 解释器执行配方命令——这使得配方即使没有 Bash 也可移植到 Windows——并可通过比较 `sources` 和 `generates` 指纹跳过已经是最新的工作<sup>[13](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)</sup>。Taskfile 不采用时间戳，而是对每个依赖项取校验和，并将其保存到本地 `.task` 目录<sup>[14](https://appliedgo.net/spotlight/just-make-a-task/)</sup>。

一位实践者的建议是：在 macOS 和 Linux 上，若 Make 用得顺手，就继续使用；新仓库若想要更友好的命令运行器，选择 Just；若需要原生 Windows 支持或基于指纹的跳过，选择 Task<sup>[13](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)</sup>。Just 手册本身列出的替代品包括 make、task、maid、cargo-make、mmake、robo、mask 和 makesure<sup>[15](https://just.systems/man/en/alternatives-and-prior-art.html)</sup>。

对于 Node.js 项目，Just 被定位为 npm 脚本的更稳健替代方案；`just-install` 包作为 `npm install` 的一部分安装本地、平台特定的二进制文件，使 `just` 可在 npm 脚本或 npx 中使用<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。

## 并行性与性能

Just 的并行性按配方限定且需选择加入。依赖项可通过 `[parallel]` 属性并行运行，同时运行的配方数量可通过 1.56.0 中加入的 `--jobs` 选项限制<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。没有全局 `-j N` 作业数标志，也没有自动的跨配方并行，这比 Make 的仓库范围 `-j` 或 Task 的并行依赖默认值模型更窄；`[parallel]` 属性在 1.47.1 中经过改进，可阻塞等待正在运行的并行依赖<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup>。

默认情况下，配方每次被调用时都会运行；不稳定的 `[cache]` 属性可以跳过未变化的工作<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup><sup> • </sup><sup>[17](https://faun.dev/toolbox/just/review/)</sup>。单个无运行时依赖的 Rust 二进制文件使其可以直接放到 CI 运行器上<sup>[3](https://vo.rs/story/just-and-task-modern-alternatives-to-make-that-dont-make-you-cry/)</sup>。

## 采用情况与生态系统

Just 已打包到许多生态系统中，可通过 conda-forge、Homebrew、Nix、npm（作为 `rust-just`）和 pipx 安装<sup>[16](https://just.systems/man/en/packages.html)</sup>。在 crates.io 上，该 crate 版本为 1.58.0，总下载量 2,779,610 次，近期下载量 541,393 次<sup>[6](https://crates.io/crates/just)</sup>。Homebrew 公式记录到 30 天内 22,719 次安装、90 天内 110,988 次、365 天内 417,985 次<sup>[8](https://formulae.brew.sh/formula/just)</sup>。在 LWN 文章发表时，已有近 200 人为该项目做出贡献，发布版本是频繁的次要版本流，而非主要版本<sup>[4](https://lwn.net/Articles/1047715/)</sup>。对于 CI 和编辑器集成，Just 可在流行的包管理器中获得，并有用于语法高亮和补全的编辑器和 shell 插件<sup>[10](https://spin.atomicobject.com/just-task-runner/)</sup>。

## 发布历史与近期变更

Just 于 2016 年 10 月 23 日首次发布为 0.0.0，2021 年 10 月达到 1.0.0，此后一直处于 1.x，并书面承诺发布不会破坏现有 justfile<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup><sup> • </sup><sup>[17](https://faun.dev/toolbox/just/review/)</sup>。通过 `mod` 语句实现的模块在 1.19.0 中引入，并在 1.31.0 中稳定<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。较新的增补包括：1.32.0 中的 `[script(COMMAND)]` 属性；1.52.0 中的 `set default-script := true`（使配方默认成为脚本配方，除非被 `[shell]` 属性覆盖）；1.54.0 中用于跳过未变化工作的不稳定的 `[cache]` 属性；1.56.0 中的 `--jobs`；以及 1.58.0 中用于按配方设置命令时间戳的 `[timestamp]` 属性<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup><sup> • </sup><sup>[17](https://faun.dev/toolbox/just/review/)</sup>。2026 年 1 月至 8 月间发布了 16 个版本，项目的 CI 测试 Linux、macOS 和 Windows<sup>[17](https://faun.dev/toolbox/just/review/)</sup>。新行为通过设置和配方属性引入，而非破坏格式的更改，因此多年前编写的 justfile 仍可运行<sup>[7](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)</sup>。

## 实际考虑与常见陷阱

**Windows。** Just 在 Windows 上可使用 Git for Windows、GitHub Desktop 或 [Cygwin](https://www.edgepedia.org/zh/cygwin) 提供的 `sh` 工作，建议大多数 Windows 用户使用 [PowerShell](https://www.edgepedia.org/zh/powershell)<sup>[5](https://github.com/casey/just?tab=readme-ov-file)</sup>。`shell` 设置上的 `[windows]` 属性可选择不同的 shell<sup>[1](https://just.systems/man/en/introduction.html)</sup>。

**错误处理。** 失败的命令会停止运行，且没有重试；配方可以声明在其之前或之后运行的依赖项，依赖项可通过 `[parallel]` 并行运行<sup>[17](https://faun.dev/toolbox/just/review/)</sup>。执行前静态报告未知配方和循环依赖，可减少对格式错误文件的调试<sup>[1](https://just.systems/man/en/introduction.html)</sup>。

**时间戳何时重要。** 对于确实需要变更重建行为的工作流，可以在配方内部用 shell 内建命令（如 `test $INFILE -nt $OUTFILE`）近似时间戳语义，或者像 checkexec 这样的工具可能更合适<sup>[10](https://spin.atomicobject.com/just-task-runner/)</sup>。1.54.0 中引入的不稳定的 `[cache]` 属性是项目自身迈向跳过未变化工作的一步<sup>[17](https://faun.dev/toolbox/just/review/)</sup>。

## References

1. [Introduction, Just Programmer's Manual](https://just.systems/man/en/introduction.html)
2. [Just Hack, Casey Rodarmor's Blog](https://casey.github.io/blog/just-hack/)
3. [Just and Task: Modern Alternatives to Make That Don't Make You Cry](https://vo.rs/story/just-and-task-modern-alternatives-to-make-that-dont-make-you-cry/)
4. [Just: a command runner, LWN.net](https://lwn.net/Articles/1047715/)
5. [casey/just README, GitHub repository](https://github.com/casey/just?tab=readme-ov-file)
6. [just on crates.io](https://crates.io/crates/just)
7. [Just (Polyglot), Sparkles monorepo tooling survey](https://sparkles-docs.pages.dev/research/monorepo-tooling/just/)
8. [Homebrew Formulae: just](https://formulae.brew.sh/formula/just)
9. [Remove dependency on make, casey/just issue #1](https://github.com/casey/just/issues/1)
10. [Just vs. Make: Which Task Runner Stands Up Best?, Atomic Object](https://spin.atomicobject.com/just-task-runner/)
11. [What are the idiosyncrasies of Make that Just avoids?, Just Programmer's Manual](https://just.systems/man/en/what-are-the-idiosyncrasies-of-make-that-just-avoids.html)
12. [The human urge to replace Makefiles with something more modern, clientserver.dev](https://www.clientserver.dev/p/the-human-urge-to-replace-makefiles)
13. [Task Runners and an Internal Developer CLI](https://www.local-environment-automation.com/developer-onboarding-architecture-friction-mapping/task-runners-and-developer-cli/)
14. [Just Make a Task (Make vs. Taskfile vs. Just), Applied Go](https://appliedgo.net/spotlight/just-make-a-task/)
15. [Alternatives and Prior Art, Just Programmer's Manual](https://just.systems/man/en/alternatives-and-prior-art.html)
16. [Packages, Just Programmer's Manual](https://just.systems/man/en/packages.html)
17. [just Review: Score, Pros and Cons, faun.dev](https://faun.dev/toolbox/just/review/)

---
*Initially written Oct 15, 2026 · Edited: Oct 25, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 软件与编程 › Development tools and collaboration infrastructure › Build, deployment, and development tooling › Build systems and build tools

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/just-command-runner

English original: https://www.edgepedia.org/just-command-runner
