Skip to content

Conversation

mikkelhegn
Copy link
Contributor

Using componentize-py as a dependency from another project (following these instructions: #160), it fails to build with the following error:

Compiling componentize-py-shared v0.1.0 (/Users/mikkel/code/fermyon/componentize-py/shared)
error[E0277]: the trait bound `getrandom::Error: std::error::Error` is not satisfied
   --> /Users/mikkel/code/fermyon/componentize-py/test-generator/src/lib.rs:549:40
    |
549 |         getrandom::getrandom(&mut seed)?;
    |                                        ^ the trait `std::error::Error` is not implemented for `getrandom::Error`
    |
    = help: the trait `FromResidual<Result<Infallible, E>>` is implemented for `Result<T, F>`
    = note: required for `anyhow::Error` to implement `From<getrandom::Error>`
    = note: required for `Result<(), anyhow::Error>` to implement `FromResidual<Result<Infallible, getrandom::Error>>

Consulting with @alexcrichton (thank you) I got the following:

This has to do with version/feature resolution in Rust where componentize-py has a Cargo.lock which uses one set of dependencies/versions but when you build externally you don't start with that so by default you pull in newer versions of dependencies. This uncovers a preexisting bug in componentize-py where it's accidentally relying on a crate feature being enabled for a crate without explicitly enabling it. That happens to work within componentize-py because some other crate enables the feature (somehow, transitively, etc) but doesn't work externally because nothing else enables it.

The "true fix" is to change test-generator's dependency on getrandom to getrandom = { version = "0.2.15", features = ['std'] }. A "workaround fix" would be to add that dependency directive to your own Cargo.toml

I've validated the below fix in my instance of referencing componentize-py from another project.

Signed-off-by: Mikkel Mørk Hegnhøj <[email protected]>
Copy link
Collaborator

@dicej dicej left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@dicej dicej merged commit 309a28b into bytecodealliance:main Aug 11, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants