I’m trying to build a Rust crate to the wasm32-unknown-unknown
target, and that fails, unexpectedly so.
Let me explain:
- First off, I have
rustup
installed via nix, and cargo, rustc et al installed via rustup - I am using the
nixos-unstable
channel - For now I am using a nix shell by executing
nix-shell -p wasm-pack zlib pkgconf
(note zlib here) - Within that nix-shell I then try to build my library with
wasm-pack build --target=nodejs
- Building the crate with
cargo build
orcargo build --release
works just fine. So do executingcargo test
andcargo test --release
i.e. it’s not an issue with the crate itself
Furthermore, this is the output of rustup show
:
Default host: x86_64-unknown-linux-gnu
rustup home: /home/j/.rustup
installed toolchains
--------------------
stable-x86_64-unknown-linux-gnu (default)
nightly-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-unknown-linux-gnu
active toolchain
----------------
stable-x86_64-unknown-linux-gnu (default)
rustc 1.77.0 (aedd173a2 2024-03-17)
Executing wasm-pack build --target=nodejs
yields a wall of text ending in
= note: rust-lld: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
This is strange because I explicitly request zlib when opening my nix-shell.
Does anyone have any ideas w.r.t what could be causing this? Any help would be greatly appreciated.