构建特定的板条箱不会重用完整工作区构建中的工件

Ale*_*xey 5 rust rust-cargo

我使用包含项目的货物工作区。当我跑步时

cargo build
Run Code Online (Sandbox Code Playgroud)

它从工作区根目录构建所有项目成员(如果我错了,请纠正我)。

然后,当我想从我使用的工作区构建特定项目时

cargo build -p my_project_1
Run Code Online (Sandbox Code Playgroud)

看起来它开始构建 my_project_1 依赖项。尽管所有依赖项都应该在第一 cargo build 阶段构建。

如何使用第一阶段完成的依赖项构建缓存?

The*_*des 1

看起来最近的货物更新已经解决了这个问题cargo build现在应该会产生如下错误消息:

\n
error: failed to compile `doomed-to-fail v0.1`, intermediate artifacts can be found at \'/some/tmp/directory\'\n    To reuse those artifacts, set the environment variable `CARGO_TARGET_DIR` to that path.\n
Run Code Online (Sandbox Code Playgroud)\n

即使使用打印额外有用的错误消息的旧版本的货物,您仍然可以设置CARGO_TARGET_DIR为重新使用现有的工件。我可以确认这适用于 Cargo 1.70.0(在使用 MacPorts 的 macOS 系统上):

\n
error: failed to compile `doomed-to-fail v0.1`, intermediate artifacts can be found at \'/some/tmp/directory\'\n    To reuse those artifacts, set the environment variable `CARGO_TARGET_DIR` to that path.\n
Run Code Online (Sandbox Code Playgroud)\n

实际失败之前出现的 91 个依赖项没有按照预期重新构建。

\n