Rust package (ruff) fails to build (only) in sandbox

I am trying to update ruff from 0.5.0 to 0.5.1.

The build fails with:

thread 'main' panicked at cargo-auditable/src/collect_audit_data.rs:77:9:
cargo metadata failure: warning: `/build/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
error: Package `ruff_python_ast v0.0.0 (/build/source/crates/ruff_python_ast)` does not have feature `schemars`. It has an optional dependency with that name, but that dependency us>

note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: could not compile `ruff_python_formatter` (bin "ruff_python_formatter")

However, running the exact same build command:

CC_X86_64_UNKNOWN_LINUX_GNU=/nix/store/kp2j7yn0wzwq5piy494r54dafrh83s6s-gcc-wrapper-13.3.0/bin/cc \
CXX_X86_64_UNKNOWN_LINUX_GNU=/nix/store/kp2j7yn0wzwq5piy494r54dafrh83s6s-gcc-wrapper-13.3.0/bin/c++ \
CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=/nix/store/kp2j7yn0wzwq5piy494r54dafrh83s6s-gcc-wrapper-13.3.0/bin/cc \
CARGO_BUILD_TARGET=x86_64-unknown-linux-gnu \
HOST_CC=/nix/store/kp2j7yn0wzwq5piy494r54dafrh83s6s-gcc-wrapper-13.3.0/bin/cc \
HOST_CXX=/nix/store/kp2j7yn0wzwq5piy494r54dafrh83s6s-gcc-wrapper-13.3.0/bin/c++ \
cargo build -j 12 --target x86_64-unknown-linux-gnu --offline --profile release

from the nix-build -A ruff.src folder (i.e. same exact source) works perfectly fine.

Note:

  • I manually added --target-dir /tmp/ruff-target to the build command because we can’t write in the nix store
  • This was executed from nix-shell -p rust-jemalloc-sys, the only dependency for this package

Bisect

I have bisected this error to the following commit:

What could be wrong here ? Is it an upstream issue ?
I reported it upstream and they don’t seem to know what it could be.

→ PR: ruff: 0.5.0 -> 0.5.1 by GaetanLepage · Pull Request #324823 · NixOS/nixpkgs · GitHub

Edit: solution (still unclear)

By applying this patch, the issue goes away. However, this does not explain why the compilation succeeds outside of the nix build environment but fails within…

This has been solved.
It was caused by a behavior specific behavior of cargo auditable (which is used in nixpkgs).

See Explicitly add schemars to ruff_python_ast Cargo.toml by GaetanLepage · Pull Request #12275 · astral-sh/ruff · GitHub for the details.