Vic*_*lyk 1 rust rust-cargo rustup rust-wasm
为什么在安装时cargo build --target wasm32-wasi会抛出错误并提示没有安装。\n重现的步骤wasm32-wasi
接下来是控制台的输出
\n\xe2\x9e\x9c train git:(master) \xe2\x9c\x97 cargo build --target wasm32-wasi\n Compiling train v0.1.0 (/user/playground/rustLang/train)\nerror[E0463]: can't find crate for `std`\n |\n = note: the `wasm32-wasi` target may not be installed\n = help: consider downloading the target with `rustup target add wasm32-wasi`\n\nerror: cannot find macro `println` in this scope\n --> src/main.rs:2:5\n |\n2 | println!("hello");\n | ^^^^^^^\n\nerror: requires `sized` lang_item\n\nFor more information about this error, try `rustc --explain E0463`.\nerror: could not compile `train` due to 3 previous errors\n\xe2\x9e\x9c train git:(master) \xe2\x9c\x97 rustup target add wasm32-wasi\ninfo: component 'rust-std' for target 'wasm32-wasi' is up to date\n\xe2\x9e\x9c train git:(master) \xe2\x9c\x97 \nRun Code Online (Sandbox Code Playgroud)\n
小智 8
我有同样的问题。我在 MacOS 上:
\n\xe2\x9d\xae cargo wasi build --release \nerror: failed to find the `wasm32-wasi` target installed, and rustup is also not detected, you\'ll need to be sure to install the `wasm32-wasi` target before using this command\nRun Code Online (Sandbox Code Playgroud)\n事实证明,我使用的是 Rust 的自制安装:
\n\xe2\x9d\xaf which cargo \n/opt/homebrew/bin/cargo\nRun Code Online (Sandbox Code Playgroud)\n解决方案是卸载 rust 的自制版本,然后按照 rust-lang.org 上的说明安装该版本(实际代码可能有所不同。只需访问https://www.rust-lang.org/tools/install并按照说明)
\n\xe2\x9d\xaf brew uninstall rust \nUninstalling /opt/homebrew/Cellar/rust/1.67.1... (36,648 files, 891.6MB)\n\n\xe2\x9d\xaf curl --proto \'=https\' --tlsv1.2 -sSf https://sh.rustup.rs | sh\nRun Code Online (Sandbox Code Playgroud)\n