Description
Rustler's forced-recompile path passes --cfg directly to cargo rustc without Cargo's -- separator. Cargo rejects the argument, so any build that reaches this recovery path fails even when the initial crate compilation succeeded.
This is present in rustler 0.38.0 and still present on current master in rustler_mix/lib/rustler/compiler.ex:
args ++ ["--cfg", "build_#{System.system_time(:millisecond)}"]
Reproduction
Configure a NIF crate whose package name contains a hyphen, for example potamid-nif.
- Cargo builds
libpotamid_nif.so and Rustler copies it as potamid_nif.so.
expected_files/1 derives the expected name from config.crate verbatim, so it looks for potamid-nif.so.
- The mismatch triggers the forced recompile.
- The retry invokes the equivalent of:
cargo rustc ... --cfg build_...
and fails:
error: unexpected argument '--cfg' found
tip: to pass '--cfg' as a value, use '-- --cfg'
The first build completed and copied the artifact; only the recovery build fails.
Expected behavior
- Rust compiler flags on the forced-recompile path are passed after Cargo's
-- separator.
- Expected library filenames account for Cargo's hyphen-to-underscore normalization, so a valid hyphenated crate does not spuriously enter recovery.
Workaround
Name the crate with an underscore so config.crate matches Cargo's artifact name and the broken retry is not reached.
Local tracking and full output: https://github.com/nymph-ai/nymphai/issues/1140
Environment
- rustler 0.38.0
- Linux x86_64
- current Cargo (error reproduced through
cargo rustc)
Description
Rustler's forced-recompile path passes
--cfgdirectly tocargo rustcwithout Cargo's--separator. Cargo rejects the argument, so any build that reaches this recovery path fails even when the initial crate compilation succeeded.This is present in rustler 0.38.0 and still present on current
masterinrustler_mix/lib/rustler/compiler.ex:Reproduction
Configure a NIF crate whose package name contains a hyphen, for example
potamid-nif.libpotamid_nif.soand Rustler copies it aspotamid_nif.so.expected_files/1derives the expected name fromconfig.crateverbatim, so it looks forpotamid-nif.so.and fails:
The first build completed and copied the artifact; only the recovery build fails.
Expected behavior
--separator.Workaround
Name the crate with an underscore so
config.cratematches Cargo's artifact name and the broken retry is not reached.Local tracking and full output: https://github.com/nymph-ai/nymphai/issues/1140
Environment
cargo rustc)