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

"cargo run --package inner_html" fails #1862

Closed
DavidBJaffe opened this issue May 21, 2021 · 4 comments
Closed

"cargo run --package inner_html" fails #1862

DavidBJaffe opened this issue May 21, 2021 · 4 comments
Labels

Comments

@DavidBJaffe
Copy link

DavidBJaffe commented May 21, 2021

I'm on a Mac running OSX 10.15.7, using rust version 1.51.0.

I cloned yew, and from the main directory:

mac% cargo run --package inner_html
    Finished dev [unoptimized + debuginfo] target(s) in 0.10s
     Running `target/debug/inner_html`
thread 'main' panicked at 'cannot call wasm-bindgen imported functions on non-wasm targets', /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4742:9
stack backtrace:
   0: std::panicking::begin_panic
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/panicking.rs:519:12
   1: js_sys::global::get_global_object::Global::get_self::__wbg_self_bb69a836a72ec6e9
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4742:9
   2: js_sys::global::get_global_object::Global::get_self
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4742:9
   3: js_sys::global::get_global_object
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4761:29
   4: js_sys::global::GLOBAL::__init
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4720:43
   5: core::ops::function::FnOnce::call_once
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5
   6: std::thread::local::lazy::LazyKeyInner<T>::initialize
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:304:25
   7: std::thread::local::fast::Key<T>::try_initialize
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:473:31
   8: std::thread::local::fast::Key<T>::get
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:456:29
   9: js_sys::global::GLOBAL::__getit
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:183:26
  10: std::thread::local::LocalKey<T>::try_with
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:271:32
  11: std::thread::local::LocalKey<T>::with
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/std/src/thread/local.rs:248:9
  12: js_sys::global
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/js-sys-0.3.51/src/lib.rs:4722:12
  13: web_sys::window
             at /Users/david.jaffe/.cargo/registry/src/github.com-1ecc6299db9ec823/web-sys-0.3.51/src/lib.rs:31:5
  14: yew::utils::window
             at ./packages/yew/src/utils.rs:10:5
  15: yew::utils::document
             at ./packages/yew/src/utils.rs:15:5
  16: yew::start_app_with_props
             at ./packages/yew/src/lib.rs:372:9
  17: yew::start_app
             at ./packages/yew/src/lib.rs:336:5
  18: inner_html::main
             at ./examples/inner_html/src/main.rs:37:5
  19: core::ops::function::FnOnce::call_once
             at /rustc/2fd73fabe469357a12c2c974c140f67e7cdd76d0/library/core/src/ops/function.rs:227:5
@siku2
Copy link
Member

siku2 commented May 21, 2021

Consider reading the "How to run" section in the examples directory.

@siku2 siku2 added question and removed bug labels May 21, 2021
@DavidBJaffe
Copy link
Author

Thank you. I just tried that:

mac% cd inner_html/
mac% trunk serve --release
May 21 05:54:45.935  INFO 📦 starting build
May 21 05:54:45.936  INFO spawning asset pipelines
May 21 05:54:46.790  INFO building inner_html
   Compiling proc-macro2 v1.0.27
   Compiling unicode-xid v0.2.2
   Compiling syn v1.0.72
   Compiling log v0.4.14
   Compiling wasm-bindgen-shared v0.2.74
   Compiling cfg-if v1.0.0
   Compiling lazy_static v1.4.0
   Compiling bumpalo v3.6.1
   Compiling wasm-bindgen v0.2.74
   Compiling serde_derive v1.0.126
   Compiling serde v1.0.126
error[E0463]: can't find crate for `core`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if`

@teymour-aldridge
Copy link
Contributor

Installing the wasm32-unknown-unknown toolchain (rustup target add wasm32-unknown-unknown) should fix the problem.

@DavidBJaffe
Copy link
Author

Lovely, thank you both!!

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

Successfully merging a pull request may close this issue.

3 participants