Repository navigation
fix(cargo-oxide): doctor probes two toolkit tools on PATH only - #1181
Conversation
|
Fix verified, closes #1180:
The test-hermeticity blocker from the earlier version of this comment is resolved by your force-push: the real-name test is gone, the fabricated-name replacements match the sibling idiom, and the table coverage moved to source-based tests. Confirmed on a toolkit-on-PATH machine: One behavior change to note: a found nvcc whose |
df32985 to
37386c8
Compare
`cargo oxide doctor` reports the CUDA toolkit missing, and exits non-zero, on
an install where the toolkit is not on `PATH` -- immediately after reporting
four components of that same toolkit as found.
## Before -> after
Same machine, same environment, `CUDA_HOME=$HOME/cuda-13.3`, toolkit not on
`PATH`:
before after
CUDA headers (cuda.h)... ✓ .../include/cuda.h (unchanged)
CUDA toolkit (nvcc)... ✗ nvcc not found ✓ Cuda compilation tools,
release 13.3, V13.3.33
(.../cuda-13.3/bin/nvcc)
libNVVM (libnvvm.so)... ✓ libNVVM 2.0 (unchanged)
nvJitLink... ✓ nvJitLink 13.3 (unchanged)
libdevice... ✓ .../libdevice.10.bc (unchanged)
`nvcc` was present at `$CUDA_HOME/bin/nvcc` throughout, in the toolkit those
four lines resolved.
## Root cause, across all three tools
`doctor` probes three CUDA toolkit executables by two different mechanisms:
| tool | doctor | the command that uses it |
|---|---|---|
| `compute-sanitizer` | `find_cuda_toolkit_executable` | `sanitize`, same helper |
| `nvcc` | `Command::new("nvcc")`, PATH only | nothing else invokes it |
| `cuda-gdb` | `Command::new("cuda-gdb")`, PATH only | `debug`, via the helper |
`find_cuda_toolkit_executable` tries PATH, then the root from
`CUDA_TOOLKIT_PATH` / `CUDA_HOME` / `cuda-oxide.toml`, then the standard install
roots. The two bare probes see only PATH. So:
* `nvcc` is in the required tier, so a working environment sets `ok = false`
and `doctor` exits 1;
* `cuda-gdb` contradicts `cargo oxide debug`, which resolves it through the
helper -- doctor calls absent a tool the command it is predicting would find.
The toolkit-root contract is doctor's own stated model; its `cuda.h` failure
prints "Set CUDA_TOOLKIT_PATH or CUDA_HOME to a CUDA Toolkit install root".
`COMPUTE_SANITIZER_FALLBACK_PATHS` states the rule the other two break, in its
own doc comment: "Shared by `sanitize` ... and `doctor` so both use the same
discovery order by construction." That helper arrived with the
compute-sanitizer probe in NVIDIA#537 and the older probes were never moved onto it.
Exactly three toolkit executables are referenced anywhere in `cargo-oxide`, so
this is the whole affected path, not the one symptom I noticed first.
## The change
All three probes now go through `DOCTOR_TOOLKIT_TOOLS`, one table pairing each
tool with its fallbacks, resolved by `doctor_toolkit_tool`. The `cuda-gdb`
fallback list becomes `CUDA_GDB_FALLBACK_PATHS`, shared by `doctor` and
`codegen_debug`, so the two answer identically by construction rather than by
coincidence -- `codegen_debug`'s inline copy is gone.
The required/optional tiers are deliberately untouched. Whether `nvcc` should be
required at all is a policy question; this is a discovery bug, and mixing the two
would make the change harder to judge.
## Behaviour change, deliberate
A discovered `nvcc` whose `--version` fails now reports `✓ <path>` instead of
failing doctor. Previously a broken `nvcc` on PATH fell to the catch-all arm and
printed `✗ nvcc not found`, which was also wrong -- it was found. The new arm
mirrors the `compute-sanitizer` probe, which has always reported the path when
the version banner cannot be read. Recording it because it is a real change in
verdict for one input, not only a discovery fix.
## Tests
* **Table pairing** -- every entry pairs a tool with its own fallback list.
Pure, so it covers all three tools on every host; pairing `nvcc` with
`CUDA_GDB_FALLBACK_PATHS` is a one-token slip no filesystem test could see.
* **Lookup** -- each tool gets its own list and an unknown name gets none
rather than another tool's.
* **Call sites** -- every `doctor_toolkit_tool` call names a tool the table
knows, since an unknown name silently loses its standard install roots.
* **Source invariant** -- no CUDA toolkit executable may be probed with a bare
`Command::new`. Read out of the source rather than from the table, so a tool
left out of the table is still caught.
* **Single list** -- `doctor` and `debug` reference one `cuda-gdb` fallback
list; a second inline copy fails.
Every test here is hermetic: pure or source-based, no filesystem and no
environment. That is deliberate. `find_cuda_toolkit_executable` probes PATH
first through `which`, and that probe has no injection point, so a test using
real tool names asserts a temp root while resolving whatever the host has
installed. An earlier version of this commit did exactly that and passed only
because this machine has no `nvcc` on PATH -- the very configuration the fix is
about. Toolkit-root resolution itself stays covered by the existing
`sanitizer_tool_lookup_uses_project_cuda_toolkit_root`, which fabricates a name
for the same reason.
Each test confirmed to bite by breaking what it guards: mispairing the table,
probing a tool absent from it, making the lookup return one list for every
tool, and re-adding an inline `cuda-gdb` list each fail their own test.
Reverting a probe to `Command::new` does not compile; restored to its original
form so it does, it fails the source invariant and the CLI returns to
`✗ nvcc not found`.
Suite runs clean in all three host shapes: toolkit on PATH, toolkit on PATH
with `CUDA_HOME` elsewhere, and no toolkit on PATH at all.
Verified: 185 tests pass, fmt clean, `clippy --all-targets -- -D warnings`
clean, `RUSTDOCFLAGS="-D warnings" cargo doc` clean, and all guard scripts pass.
Manual `doctor` runs agree in both configurations -- toolkit on PATH and not --
resolving the same `nvcc`. Exit status on this machine is still 1, for a
genuinely absent `clang`: the fix does not paper over a real failure.
Closes NVIDIA#1180.
Signed-off-by: Vyncint Ng <[email protected]>
37386c8 to
faacc26
Compare
|
Both points addressed; force-pushed, rebased onto The blocker — you are right, and I reproduced itPutting a real-named Worth stating plainly: that test passed here only because this machine has no Rather than fabricate a name for the same filesystem test — which would then be a near-duplicate of
No filesystem, no environment, so no host shape can move them. Toolkit-root resolution itself stays covered by the existing sibling test. Suite is clean in all three shapes — toolkit on PATH, toolkit on PATH with Each still bites, confirmed by breaking what it guards: mispairing the table, probing a tool absent from it, making the lookup return one list for every tool, and re-adding an inline The behaviour change — now on the recordRecorded in the commit message under its own heading. One correction to the framing: it is slightly broader than a discovered nvcc. Before, a broken Manual doctor runs, both configurationsSame resolution either way. Exit status here is still 1, for a genuinely absent fmt, |
nihalpasham
left a comment
There was a problem hiding this comment.
Hermetic-test rework verified on a toolkit-on-PATH machine; CI green. Merging.
Closes #1180.
cargo oxide doctorreports the CUDA toolkit missing, and exits non-zero, on an install where the toolkit is not onPATH— immediately after reporting four components of that same toolkit as found.Before → after
Same machine, same environment,
CUDA_HOMEset, toolkit not onPATH:nvccwas present at$CUDA_HOME/bin/nvccthe whole time — in the very toolkit those four✓lines resolved.Root cause, across all three tools
doctorprobes three CUDA toolkit executables by two different mechanisms:doctorfinds itcompute-sanitizerfind_cuda_toolkit_executablesanitize— same helpernvccCommand::new("nvcc"), PATH onlycuda-gdbCommand::new("cuda-gdb"), PATH onlydebug— via the helperTwo consequences:
nvccsits in the required tier, so a working environment setsok = falseanddoctorexits 1.cuda-gdbcontradictscargo oxide debug, which resolves it through the helper. Doctor calls absent a tool that the command it exists to predict would find.The toolkit-root contract is doctor's own stated model — its
cuda.hfailure prints "Set CUDA_TOOLKIT_PATH or CUDA_HOME to a CUDA Toolkit install root". AndCOMPUTE_SANITIZER_FALLBACK_PATHSstates the rule the other two break, in its own doc comment: "Shared bysanitize… anddoctorso both use the same discovery order by construction." That helper arrived with the compute-sanitizer probe in #537; the older two probes were never moved onto it.Exactly three toolkit executables are referenced anywhere in
cargo-oxide, so this is the whole affected path rather than the one symptom I noticed first.The change
All three probes go through
DOCTOR_TOOLKIT_TOOLS, one table pairing each tool with its fallbacks, resolved bydoctor_toolkit_tool. Thecuda-gdblist becomesCUDA_GDB_FALLBACK_PATHS, shared bydoctorandcodegen_debug, so the two answer identically by construction rather than by coincidence —codegen_debug's inline copy is gone.Deliberately out of scope: the required/optional tiers. Whether
nvccshould be required at all is a policy question, and mixing it in would make a discovery fix harder to judge. Say the word if you want it demoted and I will do that separately.ptxasis not probed by doctor at all — also a separate coverage question.Tests
None; the fix invents no pathCommand::new, read out of the source rather than from the table, so a tool left out of the table is still caughtdoctoranddebugreference onecuda-gdbfallback list; a second inline copy failsPATH precedence is asserted end to end against the real binary rather than by mutating the process
PATH— that isunsafein edition 2024 and racy across test threads, and I would rather not add a flaky test to prove a property the CLI can demonstrate directly.Each was confirmed to bite by reverting the thing it guards:
nvccprobe restored to its original form compiles, failsno_toolkit_executable_is_probed_by_bare_path, and the CLI returns to✗ nvcc not found;cuda-gdblist fails the single-list test;ptxasprobe fails the source invariant;nvccplaced earlier on PATH still resolves from PATH, checked against the real binary.Verification
183 tests pass, fmt clean,
clippy --all-targets -- -D warningsclean,RUSTDOCFLAGS="-D warnings" cargo docclean, all guard scripts pass. Rebased ontob22efa99.Doctor's exit status on my machine is still 1, for a genuinely absent
clang— the fix does not paper over a real failure.One file. No open PR touches
crates/cargo-oxide/src/commands.rs; re-checked immediately before opening.