rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.87k stars 2.43k forks source link

`cargo build` tries to build dependencies (and dependencies of them, recursively) with ALL features enabled, ALL dependency crates included, even if they are opted-out #14892

Closed chuigda closed 5 hours ago

chuigda commented 5 hours ago

Problem

gltf crate v1.41 depends on images, images has an optional dependency ravif that is not enabled by gltf, and ravif depends wasm-bindgen-macro, which uses an unstable feature allow_internal_unstable.

However when I was trying to build a crate depending on gltf, wasm-bindgen-macro was unexpectedly built, and compiler gave me the error:

Image

I checked the project dependency with cargo tree and ravif should be the only crate using wasm-bindgen-macro. Deleting target or Cargo.lock, or even re-cloning the repository don't work.

Steps

  1. git clone https://github.com/chuigda/easy-gltf
  2. use a stable toolchain
  3. cargo build

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.83.0 (5ffbef321 2024-10-29)
release: 1.83.0
commit-hash: 5ffbef3211a8c378857905775a15c5b32a174d3b
commit-date: 2024-10-29
host: x86_64-pc-windows-msvc
libgit2: 1.8.1 (sys:0.19.0 vendored)
libcurl: 8.9.0-DEV (sys:0.4.74+curl-8.9.0 vendored ssl:Schannel)
os: Windows 10.0.17763 (Windows 10 Enterprise LTSC 2019) [64-bit]
weihanglo commented 5 hours ago

The default feature of image includes the default-formats feature, which enables avif. This is intended behavior.

chuigda commented 5 hours ago

Sorry my badness