Dioxus: Difference between revisions

m Clarify that we're downgrading the version
Showcase replacing lock file.
Line 12: Line 12:
</syntaxhighlight>There are two solutions to solving this:
</syntaxhighlight>There are two solutions to solving this:


# Downgrade ''wasm-bindgen'' to the version the ''dioxus-cli'' expects.
# Downgrade ''wasm-bindgen'' to the version that ''dioxus-cli'' expects.
# Update ''dioxus-cli'' to use a newer lock file.
# Update ''dioxus-cli'' to use a newer lock file.


Line 22: Line 22:
</syntaxhighlight>Run ''cargo update'', and you should see the version being downgraded.<syntaxhighlight lang="text">
</syntaxhighlight>Run ''cargo update'', and you should see the version being downgraded.<syntaxhighlight lang="text">
Downgrading wasm-bindgen v0.2.99 -> v0.2.97 (available: v0.2.99)
Downgrading wasm-bindgen v0.2.99 -> v0.2.97 (available: v0.2.99)
</syntaxhighlight>You will also want to ensure the version of ''wasm-bindgen-cli'' matches, which can be done via looking up the current version from the lock file. <syntaxhighlight lang="nix">
</syntaxhighlight>
 
===== Updating lock file =====
If you can't downgrade, you can instead manually update the lock file.
 
Download the source from [https://crates.io/crates/dioxus-cli crates.io] for the given version of the CLI.
 
e.g. https://crates.io/api/v1/crates/dioxus-cli/0.6.0/download
 
Extract the file, ''cd'' into the directory, and run ''cargo update''. You should be able to see the ''wasm-bindgen'' version being updated.<syntaxhighlight>
Updating wasm-bindgen v0.2.97 -> v0.2.99
</syntaxhighlight>Copy the newly updated lock file into your project (here called ''Dioxus.lock''), and override the Nixpkgs version.<syntaxhighlight lang="nix">
dioxus-cli = pkgs.dioxus-cli.overrideAttrs (_: {
  postPatch = ''
    rm Cargo.lock
    cp ${./Dioxus.lock} Cargo.lock
  '';
 
  cargoDeps = pkgs.rustPlatform.importCargoLock {
    lockFile = ./Dioxus.lock;
  };
});
</syntaxhighlight>
 
==== ''wasm-bindgen-cli version'' ====
You will also want to ensure the version of ''wasm-bindgen-cli'' matches whatever is in your lock file.<syntaxhighlight lang="nix">
cargoLock = builtins.fromTOML (builtins.readFile ./Cargo.lock);
cargoLock = builtins.fromTOML (builtins.readFile ./Cargo.lock);