Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getrandom v0.2.15 blocks uuid and compiling to wasm #17699

Open
Wehzie opened this issue Feb 6, 2025 · 4 comments
Open

getrandom v0.2.15 blocks uuid and compiling to wasm #17699

Wehzie opened this issue Feb 6, 2025 · 4 comments
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled

Comments

@Wehzie
Copy link

Wehzie commented Feb 6, 2025

What problem does this solve or what need does it fill?

Hey! I'm trying to build my bevy game for wasm32-unknown-unknown. When compiling for wasm I receive uuid couldn't build errors with could not find RngImp in imp in uuid-1.13.1/src/rng.rs:10:10. Cargo.lock has dependencies on getrandom 0.2.15 and 0.3.1. I had manually set getrandom = { version = "0.3", features = ["wasm_js"] } after following up on previous errors. I also set rustflags = ["--cfg", "getrandom_backend=\"wasm_js\""] in .cargo/config.toml.
Specifying the feature = ["wasm_js"] also requires specifying a version, setting version to "*" doesn't solve the issue either.

Following the dependency tree, the origin of these problems seems to be from bevy_utils on ahash on const-random on const-random-macro on getrandom.

getrandom v0.2.15
└── const-random-macro v0.1.16 (proc-macro)
    └── const-random v0.1.18
        └── ahash v0.8.11
            ├── bevy_utils v0.15.1
            │   ├── bevy_animation v0.15.1
            │   │   ├── bevy_gltf v0.15.1
            │   │   │   └── bevy_internal v0.15.1
            │   │   │       └── bevy v0.15.1



getrandom v0.2.15
├── ahash v0.8.11 (*)
└── rand_core v0.6.4
    ├── rand v0.8.5
    │   ├── bevy_math v0.15.1 (*)


also dependent on ahash v0.8.11:
      └── hashbrown v0.14.5
          └── bevy_utils v0.15.1 (*)

Maybe I'm on the completely wrong trail as desktop cargo run builds fine.

What solution would you like?

It seems that ahash and const-random-macro are updated only sporadically. Forking the packages to improve control over dependencies could be a solution.

What alternative(s) have you considered?

Other, more actively maintained dependencies could replace the packages in question.

Other

  • OS: Ubuntu 24.10
  • bevy 0.15.1
  • rustup 1.27.1
  • rustc 1.83.0
@Wehzie Wehzie added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 6, 2025
@bushrat011899
Copy link
Contributor

As a workaround, can you try adding the following to you Cargo.toml:

[target.'cfg(target_arch = "wasm32")'.dependencies]
uuid = { version = "1.13.1", default-features = false, features = ["js"] }

This enables the js feature in uuid which should resolve the issues you're experiencing.

@simbleau
Copy link
Contributor

simbleau commented Feb 6, 2025

We also just started getting this today - Screwing up our entire pipeline atm.

As a workaround, can you try adding the following to you Cargo.toml:

[target.'cfg(target_arch = "wasm32")'.dependencies]
uuid = { version = "1.13.1", default-features = false, features = ["js"] }

This enables the js feature in uuid which should resolve the issues you're experiencing.

Note for anyone who comes across this, this may not be enough.

You may also need to add this to a .cargo/config.toml:

[target.'cfg(target_family = "wasm")']
rustflags = ['--cfg=getrandom_backend="wasm_js"']

github-merge-queue bot pushed a commit to linebender/bevy_vello that referenced this issue Feb 6, 2025
Our pipeline in #90 is unable to merge due to
bevyengine/bevy#17699

This PR fixes the issue with a workaround. Stage the Cargo.lock, and fix
the transitive dependency on getrandom.

Dually Closes #91 and unblocks #90
@Wehzie
Copy link
Author

Wehzie commented Feb 6, 2025

Thank you the fix works. To summarize,

my Cargo.toml looks as follows

[dependencies]
bevy = "0.15.1"
rand = "0.9.0"
getrandom = { version = "0.3", features = ["wasm_js"] }

[target.'cfg(target_arch = "wasm32")'.dependencies]
uuid = { version = "1.13.1", default-features = false, features = ["js"] }

and .cargo/config.toml

[target.'cfg(target_family = "wasm")']
runner = "wasm-server-runner"
rustflags = ['--cfg=getrandom_backend="wasm_js"']

@mockersf
Copy link
Member

mockersf commented Feb 7, 2025

this should be fixed with the update to Bevy 0.15.2

github-merge-queue bot pushed a commit to linebender/bevy_vello that referenced this issue Feb 7, 2025
We no longer need to pin getrandom's backend due to a transitive
dependency in uuid. This was fixed today by
bevyengine/bevy#17699 (comment)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

4 participants