I have come to understand that cargo help build is supposed to give detailed documentation for the cargo build command + argument. However, instead, on NetBSD at least, doing cargo help build results in
$ cargo help build
man: no entry for ./cargo-build.kHvBod in the manual.
$
Instead, I understand that it was supposed to show the man page for "cargo-build".
rustc --version --verbose:
$ rustc --version --verbose
rustc 1.95.0 (59807616e 2026-04-14) (built from a source tarball)
binary: rustc
commit-hash: 59807616e1fa2540724bfbac14d7976d7e4a3860
commit-date: 2026-04-14
host: x86_64-unknown-netbsd
release: 1.95.0
LLVM version: 22.1.2
$
Details of syscall trace + patch
Doing system call trace of a cargo help build command results in among them the following name-to-inode translations (and associated goop):
25590 25590 cargo CALL chdir(0x768978d09998)
25590 25590 cargo NAMI "/tmp"
25590 25590 cargo RET chdir 0
...
25590 25590 cargo CALL execve(0x7f7fffc027a0,0x768978d6ca60,0x768978d84000)
25590 25590 cargo NAMI "/usr/bin/man"
25590 25590 cargo NAMI "/usr/libexec/ld.elf_so"
25166 25166 cargo GIO fd 4 read 0 bytes
""
25166 25166 cargo RET read 0
25166 25166 cargo CALL close(4)
25166 25166 cargo RET close 0
...
25590 25590 man NAMI "/etc/man.conf"
25590 25590 man RET open 3
...
25590 25590 man CALL __lstat50(0x7f7fffde9d00,0x7f7fffdea150)
25590 25590 man NAMI "./cargo-build.Yng6xQ"
25590 25590 man RET __lstat50 0
25590 25590 man CALL write(2,0x7f7fffdebcc0,5)
25590 25590 man GIO fd 2 wrote 5 bytes
"man: "
25590 25590 man RET write 5
25590 25590 man CALL write(2,0x7f7fffdebda0,0x30)
25590 25590 man GIO fd 2 wrote 48 bytes
"no entry for ./cargo-build.Yng6xQ in the manual."
25590 25590 man RET write 48/0x30
25590 25590 man CALL write(2,0x71f29f1cfb87,1)
25590 25590 man GIO fd 2 wrote 1 bytes
"\n"
25590 25590 man RET write 1
I understand that the code which puts together the man command comes from
src/tools/cargo/src/bin/cargo/commands/help.rs's write_and_spawn() function. Furthermore, the following patch makes this work at least on NetBSD:
--- src/tools/cargo/src/bin/cargo/commands/help.rs.orig 2026-04-19 19:43:27.728526123 +0000
+++ src/tools/cargo/src/bin/cargo/commands/help.rs
@@ -141,7 +141,11 @@ fn write_and_spawn(name: &str, contents: &[u8], comman
/// display it.
fn write_and_spawn(name: &str, contents: &[u8], command: &str) -> CargoResult<()> {
let prefix = format!("cargo-{}.", name);
- let mut tmp = tempfile::Builder::new().prefix(&prefix).tempfile()?;
+ let suffix = if command == "man" { ".1" } else { "" };
+ let mut tmp = tempfile::Builder::new()
+ .prefix(&prefix)
+ .suffix(suffix)
+ .tempfile()?;
let f = tmp.as_file_mut();
f.write_all(contents)?;
f.flush()?;
I'll not claim that this patch is universally acceptable, but at least it points in the direction of which function needs a patch.
I have come to understand that
cargo help buildis supposed to give detailed documentation for thecargo buildcommand + argument. However, instead, on NetBSD at least, doingcargo help buildresults inInstead, I understand that it was supposed to show the man page for "cargo-build".
rustc --version --verbose:Details of syscall trace + patch
Doing system call trace of a
cargo help buildcommand results in among them the following name-to-inode translations (and associated goop):I understand that the code which puts together the
mancommand comes fromsrc/tools/cargo/src/bin/cargo/commands/help.rs'swrite_and_spawn()function. Furthermore, the following patch makes this work at least on NetBSD:I'll not claim that this patch is universally acceptable, but at least it points in the direction of which function needs a patch.