rustrust-cargotauriwasm-bindgen

Unable to resolve wasm-bindgen dependency conflict


I'm using Tauri v2. I'm trying to add the amazing photon_rs crate for image manipulation.

When I run cargo run I can see there's a version conflict with wasm-bindgen:

Updating crates.io index
error: failed to select a version for `wasm-bindgen`.
    ... required by package `wasm-streams v0.4.1`
    ... which satisfies dependency `wasm-streams = "^0.4"` of package `reqwest v0.12.0`
    ... which satisfies dependency `reqwest = "^0.12"` of package `tauri v2.0.0`
    ... which satisfies dependency `tauri = "^2"` of package `blurryface v0.0.0 (/Users/jacharles/dev_freelance/tauri-apps/blurryface/src-tauri)`
versions that meet the requirements `^0.2.87` are: 0.2.92, 0.2.95, 0.2.93, 0.2.91, 0.2.90, 0.2.89, 0.2.87

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.78`
    ... which satisfies dependency `wasm-bindgen = "=0.2.78"` of package `photon-rs v0.3.2`
    ... which satisfies dependency `photon-rs = "^0.3.2"` of package `blurryface v0.0.0 (/Users/jacharles/dev_freelance/tauri-apps/blurryface/src-tauri)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

The thing is... I'm not using (or planning on using) wasm for either tauri or photon_rs

Looks like photon added support to exclude building wasm deps via a feature flag, but it doesn't appear to be working for me.

I added this to my cargo.toml (but it seems to have no effect?)

photon-rs = { version = "0.3.2", default-features = false } # disables wasm?

My hunch is that wasm-bindgen is being re-enabled for the whole tree because tauri lists it as a dependency.

Running cargo update --package wasm-bindgen shows this error:

 Updating crates.io index
error: failed to select a version for `wasm-bindgen`.
    ... required by package `softbuffer v0.4.0`
    ... which satisfies dependency `softbuffer = "^0.4"` of package `tauri-runtime-wry v2.1.2`
    ... which satisfies dependency `tauri-runtime-wry = "^2.1.2"` of package `tauri v2.0.6`
    ... which satisfies dependency `tauri = "^2.0.0"` of package `tauri-plugin-shell v2.0.0`
    ... which satisfies dependency `tauri-plugin-shell = "^2"` of package `blurryface v0.0.0 (/Users/jacharles/dev_freelance/tauri-apps/blurryface/src-tauri)`
versions that meet the requirements `^0.2.86` are: 0.2.95, 0.2.93, 0.2.92, 0.2.91, 0.2.90, 0.2.89, 0.2.87, 0.2.86

all possible versions conflict with previously selected packages.

  previously selected package `wasm-bindgen v0.2.78`
    ... which satisfies dependency `wasm-bindgen = "=0.2.78"` of package `photon-rs v0.3.2`
    ... which satisfies dependency `photon-rs = "^0.3.2"` of package `blurryface v0.0.0 (/Users/jacharles/dev_freelance/tauri-apps/blurryface/src-tauri)`

failed to select a version for `wasm-bindgen` which could resolve this conflict

Here's my cargo.toml

[package]
name = "blurryface"
version = "0.0.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[build-dependencies]
tauri-build = { version = "2", features = [] }


# [patch.crates-io]
# wasm-bind = { git = 'https://github.com/serde-rs/serde.git' }

[dependencies]
tauri = { version = "2", features = [], default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
grep = "0.3.1"
walkdir = "2.5.0"
termcolor = "1.4.1"
ignore = "0.4.22"
tauri-plugin-dialog = "2"
tauri-plugin-shell = "2"
photon-rs = { version = "0.3.2", default-features = false } # disables wasm
# enable_wasm

Questions

  1. Can I disable wasm deps from the tauri side?
  2. What other options do I have for forcing versions?
  3. Should I just fork photon_rs and remove the deps I don't want manually?
  4. Any other options / ideas?

Solution

  • In this specific case, wasm-bindgen version =0.2.85 is a dependency of the latest published version of photon-rs. That seems like a mistake in photon-rs.

    Luckily, there is already a merged commit that relaxes the version.

    You can use it before publication by replacing your photon-rs dependency with:

    photon-rs = {
        version = "0.3.2",
        default-features = false,
        git = "https://github.com/silvia-odwyer/photon",
        rev = "3b72d357848cd76be9363e87ad0cd02a19b988d2"
    }