KarlitosVII / trilogy-save-editor

A save editor for Mass Effect Trilogy (and Legendary)
https://www.nexusmods.com/masseffectlegendaryedition/mods/20
Other
151 stars 20 forks source link

cannot call wasm-bindgen imported functions on non-wasm targets #37

Closed GDelevoye closed 2 years ago

GDelevoye commented 2 years ago

Hi !

Here is my configuration :

I compiled the last version (date: 26th of december 2021 ) because I did not trust the executable files I have found online.

I have only little knowledge in rust, and apparently it seems that a recent code refactory has added new dependencies.

I followed the compilation instructions and got an error when I reach the "make install" phase :

$ cargo make release
[cargo-make] INFO - cargo make 0.35.7
[cargo-make] INFO - Project: trilogy-save-editor
[cargo-make] INFO - Build File: Makefile.toml
[cargo-make] INFO - Task: release
[cargo-make] INFO - Profile: development
[cargo-make] INFO - Running Task: legacy-migration
[cargo-make] INFO - Execute Command: "powershell" "-Command" "npm" "run" "release"

> release
> tailwindcss -i index.css -o target/index.css --jit --minify

Done in 827ms.
[cargo-make] INFO - Execute Command: "trunk" "build" "--dist" "target/dist" "--release"
[cargo-make] ERROR - Error while executing command, error: Os {
    code: 2,
    kind: NotFound,
    message: "Le fichier spécifié est introuvable.",
}
[cargo-make] WARN - Build Failed.

It did not take much time to realize what was wrong and I simply fixed it with :

$ cargo install trunk

Then I tried a cargo run

$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.28s
     Running `target\debug\trilogy-save-editor.exe`
thread 'main' panicked at 'cannot call wasm-bindgen imported functions on non-wasm targets', C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5412:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\trilogy-save-editor.exe` (exit code: 101)

Before that, I followed all the lines of the README including the "rustup target add wasm32-unknown-unknown" line, and I tried the whole process twice

$ rustup target add wasm32-unknown-unknown
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date

With the backtrace :

$ ./trilogy-save-editor.exe
thread 'main' panicked at 'cannot call wasm-bindgen imported functions on non-wasm targets', C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5412:9
stack backtrace:
   0: std::panicking::begin_panic<str>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\panicking.rs:543
   1: js_sys::global::get_global_object::impl$2::get_self::__wbg_self_c6fbdfc2918d5e58
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5412
   2: js_sys::global::get_global_object::Global::get_self
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5412
   3: js_sys::global::get_global_object
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5431
   4: js_sys::global::GLOBAL::__init
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5390
   5: core::ops::function::FnOnce::call_once<js_sys::Object (*)(),tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
   6: std::thread::local::lazy::LazyKeyInner<js_sys::Object>::initialize<js_sys::Object,js_sys::Object (*)()>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:431
   7: std::thread::local::fast::Key<js_sys::Object>::try_initialize<js_sys::Object,js_sys::Object (*)()>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:609
   8: std::thread::local::fast::Key<js_sys::Object>::get<js_sys::Object,js_sys::Object (*)()>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:592
   9: js_sys::global::GLOBAL::__getit
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:311
  10: std::thread::local::LocalKey<js_sys::Object>::try_with<js_sys::Object,js_sys::global::closure$0,js_sys::Object>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:398
  11: std::thread::local::LocalKey<js_sys::Object>::with<js_sys::Object,js_sys::global::closure$0,js_sys::Object>
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\std\src\thread\local.rs:375
  12: js_sys::global
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\js-sys-0.3.55\src\lib.rs:5392
  13: web_sys::window
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\web-sys-0.3.55\src\lib.rs:31
  14: gloo_utils::window
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\gloo-utils-0.1.1\src\lib.rs:6
  15: gloo_utils::document
             at C:\Users\delev\.cargo\registry\src\github.com-1ecc6299db9ec823\gloo-utils-0.1.1\src\lib.rs:11
  16: trilogy_save_editor::main
             at C:\Users\delev\Documents\trilogy-save-editor\src\main.rs:17
  17: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Seems like a wasm issue. The problem is; I have no idea what it is because I don't do web dev

Googling did not help me

KarlitosVII commented 2 years ago

With cargo run your are trying to execute the wasm as .exe. The release command (or run) compile the wasm then compile the app and package them together.

Now you have all the prerequisite cargo make release or cargo make run for debug should work as expected.