Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hello World doesn't work on M1 mac #951

Open
rodya-mirov opened this issue Feb 22, 2025 · 2 comments
Open

Hello World doesn't work on M1 mac #951

rodya-mirov opened this issue Feb 22, 2025 · 2 comments

Comments

@rodya-mirov
Copy link

What I did (following the instructions https://trunkrs.dev/#install as well as possible):

  • rustup target add wasm32-unknown-unknown
  • cargo install --locked trunk
  • cargo install --locked wasm-bindgen-cli

Created a new project: cargo new chip8

Went into the project. Copied the sample code here into the top of the repo:

<html>
  <head>
    <link data-trunk rel="scss" href="path/to/index.scss"/>
  </head>
</html>

Then trunk build failed to build due to that path not resolving; I created a blank scss file at the top of the repo, adjusted the path to point to it, then tried again:

$ trunk build
2025-02-22T18:58:01.382159Z  INFO 🚀 Starting trunk 0.21.7
2025-02-22T18:58:01.431624Z  INFO 📦 starting build
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.00s
error: failed to find intrinsics to enable `clone_ref` function
2025-02-22T18:58:01.562214Z ERROR ❌ error
error from build pipeline

Caused by:
    0: HTML build pipeline failed (1 errors), showing first
    1: error from asset pipeline
    2: running wasm-bindgen
    3: wasm-bindgen call to executable '[myhome]/.cargo/bin/wasm-bindgen' with args: '["--target=web", "--out-dir=[projectdir]/chip8/target/wasm-bindgen/debug", "--out-name=chip8", "[projectdir]/chip8/target/wasm32-unknown-unknown/debug/chip8.wasm", "--no-typescript"]' returned a bad status: exit status: 1
2025-02-22T18:58:01.562232Z ERROR error from build pipeline
2025-02-22T18:58:01.562235Z  INFO   1: HTML build pipeline failed (1 errors), showing first
2025-02-22T18:58:01.562236Z  INFO   2: error from asset pipeline
2025-02-22T18:58:01.562238Z  INFO   3: running wasm-bindgen
2025-02-22T18:58:01.562239Z  INFO   4: wasm-bindgen call to executable '[myhome]/.cargo/bin/wasm-bindgen' with args: '["--target=web", "--out-dir=[projectdir]/chip8/target/wasm-bindgen/debug", "--out-name=chip8", "[projectdir]/chip8/target/wasm32-unknown-unknown/debug/chip8.wasm", "--no-typescript"]' returned a bad status: exit status: 1
FAIL

I'm not sure what's happening here. The trunk build seems to be failing due to a wasm-bindgen failure; I assume this is the error above, whatever that is -- failed to find intrinsics to enable clone_ref function. I have no idea what this means, but considering my rust file is just fn main() {} I'm not sure what to do about it.

Is there more setup to be done here? I tried to follow the hello world guide pretty closely, so I'm not really sure where I could have gone wrong (I did find that target myself, so maybe I did that wrong, I'm not sure).

@rodya-mirov
Copy link
Author

I'm going to leave this open in case it's of use to the maintainers but I now think it's a documentation bug; I followed the steps in https://trunkrs.dev/guide/getting-started/project.html and it worked flawlessly. I would suggest moving the content from the guide into the website, or making the website redirect to the guide, or something like that; but I see that there are a number of open issues about that, so it's a known issue.

Anyway let me take the time to say thank you all for the work you do 🙏 I'm thrilled to have it working locally with (comparatively) little effort.

@ineiti
Copy link

ineiti commented Feb 24, 2025

It's a strange issue. I removed all crates from Cargo.toml, except console_error_panic_hook, and then used this in the main:

fn main() {
    console_error_panic_hook::set_once();
}

That's enough to make the error disappear. But so is having web_sys in the Cargo.toml, and add a use web_sys; to the main.rs. However, removing the unused use web_sys; from the main.rs makes the error re-appear again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants