[GH CI] Enzyme library lookup in ci.yml has no empty-result guard
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 14
- Forks
- 2
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 61
Description
Two jobs in ci.yml find the Enzyme plugin and write its path into $GITHUB_ENV:
ENZYME_LIB=$(find "$(pwd)/.cargo/enzyme" -name 'LLVMEnzyme*.so' | head -n 1)
echo "ENZYME_LIB=$ENZYME_LIB" >> "$GITHUB_ENV"
The same two lines appear twice (the main test job and the autodiff job). Neither checks whether
find actually found anything.
Why an empty value is worse than no value
scripts/provision/install_enzyme.sh already does this lookup, and it does guard the result:
ENZYME_LIB=$(find "$DEST_DIR" -name "LLVMEnzyme*.$LIB_EXT" | head -n 1)
if [ -z "$ENZYME_LIB" ]; then
echo "Error: Could not find the Enzyme library."
exit 1
fi
The CI copy drops that check. If the search path and the script's $DEST_DIR ever drift apart,
or the installed layout changes, find prints nothing, and CI writes a line that sets the
variable to the empty string.
An empty environment variable is not the same as an unset one. The test that decides whether to
skip the autodiff tests asks whether the variable is missing:
if std::env::var("ENZYME_LIB").is_err() { /* skip */ }
With ENZYME_LIB= exported, var() returns Ok(""), so the skip never happens. The tests run,
hand an empty plugin path to MLIR, and fail with a confusing error instead of the clear
"Enzyme is not installed" skip that was intended.
The CI copy also hardcodes .so, so the Linux/macOS extension logic is duplicated as well.
Suggested fix
Either add the guard next to each find:
ENZYME_LIB=$(find "$(pwd)/.cargo/enzyme" -name 'LLVMEnzyme*.so' | head -n 1)
[ -n "$ENZYME_LIB" ] || { echo "error: Enzyme library not found under $(pwd)/.cargo/enzyme" >&2; exit 1; }
echo "ENZYME_LIB=$ENZYME_LIB" >> "$GITHUB_ENV"
or, better, let install_enzyme.sh write $GITHUB_ENV itself, so the lookup lives in exactly one
place and the guard cannot be forgotten again.
Found while reviewing #628, but these lines are on main already and are not caused by that PR.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the two Enzyme lookup blocks in ci.yml and compare them with scripts/provision/install_enzyme.sh, including the Rust check for ENZYME_LIB. Verify both CI jobs handle a missing library without exporting an empty value, and confirm the intended Linux/macOS library handling remains consistent. Done means the autodiff tests skip clearly when Enzyme is unavailable and CI still uses the discovered library when present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- github-actions, rust, shell
- Domain
- ci-cd
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100