Complex Build (Rust + JS)

Site name: astonishing-muffin-30b635.netlify.app

I am attempting to build an app that requires building first a rust WASM portion using wasm-pack, and then a vue webapp.

What is the normal process to do something like this? In a normal CLI it woud look something like:

cargo install wasm-pack
yarn wasm
yarn build

Logs:

7:41:51 PM: $ rustup default stable & cargo install wasm-pack & yarn wasm & yarn build
7:41:51 PM: info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
7:41:51 PM: error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.
7:41:51 PM: info: latest update on 2025-12-11, rust version 1.92.0 (ded5c06cf 2025-12-08)
7:41:51 PM: info: downloading component 'cargo'
7:41:51 PM: yarn run v1.22.22
7:41:51 PM: warning package.json: No license field
7:41:51 PM: $ vite build
7:41:51 PM: yarn run v1.22.22
7:41:51 PM: warning package.json: No license field
7:41:51 PM: $ wasm-pack build ./key_bnc_wasm --target web
7:41:51 PM: /bin/sh: 1: wasm-pack: not found
7:41:51 PM: error Command failed with exit code 127. (https://ntl.fyi/exit-code-127)
7:41:51 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:41:51 PM: info: downloading component 'clippy'
7:41:51 PM: info: downloading component 'rust-docs'
7:41:51 PM: info: downloading component 'rust-std'
7:41:51 PM: info: downloading component 'rustc'
7:41:52 PM: vite v2.6.10 building for production...
7:41:52 PM: Error: Can't find key_bnc_wasm/pkg, run wasm-pack build ./key_bnc_wasm --target web first
âś“ 0 modules transformed.

Have you tried:

rustup default stable && cargo install wasm-pack && wasm-pack build ./key_bnc_wasm --target web

Seems to be working for me.

Thank you! rustup default stable was the missing link

Another option is to use the rust-toolchain file. It should tell cargo to use the toolchain channel you specify. In the case of OP it would be stable.

You know what’s weird? I ended needing to use rustup toolchain install 1.78.0 and it was working fine.

But I just pushed a branch with some simple CSS changes, and now it has stopped working. It’s giving me the following error:

10:23:27 AM: $ rustup toolchain install 1.78.0 && cargo install wasm-pack --version=0.10.1 --locked && pnpm wasm && pnpm build
10:23:28 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
10:23:28 AM: info: syncing channel updates for '1.78.0-x86_64-unknown-linux-gnu'
10:23:28 AM:   1.78.0-x86_64-unknown-linux-gnu unchanged - rustc 1.78.0 (9b00956e5 2024-04-29)
10:23:28 AM: error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured.
help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain.

After putting a rust-toolchain.toml in the root, and removing the explicit rustup command, the latest run seems to have built fine. I still don’t know what’s up with the flakiness, though.

Glad it worked. Awesome.

It’s not flakiness. It’s the fact that assets for your builds are cached and there is some side effect causing it to fail.