Skip to content

Build cargoArtifacts (craneLib.buildDepsOnly) with the wasm32-unknown-unknown target can fail due to incompatible libs #874

Answered by ipetkov
kutu-dev asked this question in Q&A
Discussion options

You must be logged in to vote

Ah thank you for the full reproduction!

So the solution here is what I hinted at above: using a platform-specific dependency in the crate which consumes the workspace-defined dependency; by applying this diff, all three derivations successfully build in your flake:

diff --git a/crates/my-cli/Cargo.toml b/crates/my-cli/Cargo.toml
index 9787a50..1f6a5d1 100644
--- a/crates/my-cli/Cargo.toml
+++ b/crates/my-cli/Cargo.toml
@@ -3,5 +3,5 @@ name = "my-cli"
 edition.workspace = true
 publish = false
 
-[dependencies]
+[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
 cmd_lib.workspace = true

Even though workspace dependencies do not support per-platform granularity, the crates which have…

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@kutu-dev
Comment options

Answer selected by ipetkov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #873 on July 25, 2025 00:19.