yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications
https://yew.rs
Apache License 2.0
30.54k stars 1.42k forks source link

Problem with 'rust-std' component and chronos crate #115

Closed lauransauco closed 4 years ago

lauransauco commented 6 years ago

Hi everyone, I'm starting in Rust programming language and I discovered this github repository with examples I would like to test, but I have some errors I don't find the solution. First of all, I don't want to use Emscripten because I've read it's complicated and there's another way to compile in Rust without using it.

I tried to install target wasm32-unknown-unknown and asmjs-unknown-unknown in both versions (nightly and stable) but I got this kind of errors: $ rustup target add wasm32-unknown-unknown --toolchain nightly error: toolchain 'nightly-x86_64-pc-windows-msvc' does not contain component 'rust-std' for target 'wasm32-unknown-unknown' $ rustup target add asmjs-unknown-unknown error: toolchain 'stable-x86_64-pc-windows-msvc' does not contain component 'rust-std' for target 'asmjs-unknown-unknown'

I've searched in different folders and it looks like everything is well installed. For example, in rustup folder for stable version (also nightly) I have the lib folder with this components: rustc-x86_64-pc-windows-msvc rust-std-x86_64-pc-windows-msvc cargo-x86_64-pc-windows-msvc rust-docs-x86_64-pc-windows-msvc

So I don't really understand what's going on!

Also I have this other error related on crates and libraries when I try to run Counter example from this repository: $ rustc +nightly --target wasm32-unknown-unknown -O main.rs error[E0463]: can't find crate for chrono --> main.rs:1:1 | 1 | extern crate chrono; | ^^^^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

Do you have any idea why I have those errors? Can you please help me? Thank you!

fryguy1013 commented 6 years ago

Use cargo:

cargo build --target wasm32-unknown-unknown

or if you have cargo-web, then it does all the useful stuff of hosting a web server and webassembly host javascript file as well.

cargo web start --target-webasm

Although the chrono crate won't work with the wasm32-unknown-unknown target because it doesn't support non-linux and non-windows systems (whereas the wasm32-unknown-emscripten target pretends to be linux and has javascript hooks for some of the system calls I believe). I have a fix for that on my local system, but I'm unsure if it's quality enough to be checked into the chrono crate directly.