rustwasm / team

A point of coordination for all things Rust and WebAssembly
MIT License
1.45k stars 59 forks source link

The Tutorial seems to be broken #213

Closed ice-cream-coder closed 6 years ago

ice-cream-coder commented 6 years ago

After running npm run serve I get this error:

WARNING in ./wasm_game_of_life.js
36:16-38 "export '__wbindgen_malloc' (imported as 'wasm') was not found in './wasm_game_of_life_bg'
 @ ./wasm_game_of_life.js
 @ ./index.js
 @ ./bootstrap.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 ./bootstrap.js

WARNING in ./wasm_game_of_life.js
44:15-25 "export 'greet' (imported as 'wasm') was not found in './wasm_game_of_life_bg'
 @ ./wasm_game_of_life.js
 @ ./index.js
 @ ./bootstrap.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 ./bootstrap.js

WARNING in ./wasm_game_of_life.js
46:8-28 "export '__wbindgen_free' (imported as 'wasm') was not found in './wasm_game_of_life_bg'
 @ ./wasm_game_of_life.js
 @ ./index.js
 @ ./bootstrap.js
 @ multi (webpack)-dev-server/client?http://localhost:8081 ./bootstrap.js

ERROR in chunk 0
0.bootstrap.js
/home/roy/rustproj/wasm_game_of_life/wasm_game_of_life_bg.wasm
Unexpected valtype: 0x61

I inspected my wasm_game_of_lif_bg.wasm and found that all functions were defined. __wbindgen_malloc, greet, and __wbindgen_free.

scottrblock commented 6 years ago

I'm also receiving the same errors when trying to follow the tutorial. Running on macOS. Happy to provide any other helpful information.

xtuc commented 6 years ago

The root of the issue Unexpected valtype: 0x61 comes from https://github.com/xtuc/webassemblyjs, the other errors are from Webpack because we failed to "prepare" the wasm binary.

(I just need to catch my flight and i'll investigate that).

xtuc commented 6 years ago

@roydaw could you please send me the repo the tutorial points to? or the tutorial?

demurgos commented 6 years ago

@xtuc https://github.com/rustwasm/wasm_game_of_life

But I don't know which chapter has the bug.

xtuc commented 6 years ago

I can't reproduce the issue, every chapter of the wasm_game_of_life works for me.

ice-cream-coder commented 6 years ago

I tried to start the tutorial again and got hung up at a different point. I'm trying to follow this page https://rustwasm.github.io/book/game-of-life/setup.html

This time I wasn't able to build the project with npm run build-debug. I get this error:

error[E0658]: attribute procedural macros are experimental (see issue #38356)6   
 --> src/lib.rs:7:1
  |
5 | use wasm_bindgen::prelude::*;
  |     ------------------------ procedural macro imported here
6 | 
7 | #[wasm_bindgen]
  | ^^^^^^^^^^^^^^^
  |
  = help: add #![feature(proc_macro)] to the crate attributes to enable

I checked my lib.rs file and I do have this line:

#![feature(proc_macro, wasm_custom_section, wasm_import_module)]

So I have no idea why it would do that. (Using Linux, tried npm 5.5.1 and 5.6.0)

data-pup commented 6 years ago

Oh shoot, good catch! I think that proc_macro needs to be replaced with use_extern_macros. Not positive that applies here as well, but I ran into a similar issue recently!

alexcrichton commented 6 years ago

@roydaw ah for that @data-pup is correct, and I've submitted an update to the tutorial at https://github.com/rustwasm/book/pull/48

ice-cream-coder commented 6 years ago

Awesome, I past npm run build-debug now I'm back to my orignal issue. (Also, someone could look into fixing the compiler error message since it suggested to add proc_macro instead of use_extern_macros.)

alexcrichton commented 6 years ago

@roydaw have you tried updating your NPM dependencies? This may be a fixed bug in webpack perhaps? The compiler suggestion should be fixed in https://github.com/rust-lang/rust/pull/52458

ice-cream-coder commented 6 years ago

Okay! I ran npm update, and that seemed to fix the issue.

alexcrichton commented 6 years ago

Ok great! In that case sounds like this is fixed now, so closing

drachehavoc commented 4 years ago

same error here, even after execute npm update.