[英]WASM/Yew - failed to resolve: could not find `unix` in `os`
I'm building a yew app alongside a rocket backend on Windows following this tutorial (although the tutorial is for a Linux environment).按照本教程(尽管本教程适用于 Linux 环境),我正在 Windows 上构建一个 yew 应用程序和一个火箭后端。 I'm trying to build the yew app using
wasm-pack
.我正在尝试使用
wasm-pack
构建 yew 应用程序。 I'm not using the Linux subsystem to build the app, though I do have it installed.我没有使用 Linux 子系统来构建应用程序,但我确实安装了它。
I have already installed the wasm toolchain and cargo make:我已经安装了 wasm 工具链和货物 make:
rustup target add wasm32-unknown-unknown
The following is my toolchain list:以下是我的工具链列表:
stable-x86_64-pc-windows-gnu
stable-x86_64-pc-windows-msvc
nightly-x86_64-pc-windows-msvc (default)
1.30.0-x86_64-pc-windows-msvc
Here is my folder structure:这是我的文件夹结构:
Project root
├───backend <-- rocket backend
| ├───Cargo.toml
│ └───src
│ ├───bin
│ └───db
├───frontend <-- yew frontend
│ ├───pkg
│ ├───src
| ├───Cargo.toml
| └───Makefile.toml
├───src
├───Cargo.toml
└───Makefile.toml
This is rootdir\\Cargo.toml
:这是
rootdir\\Cargo.toml
:
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]
This is rootdir\\Makefile.toml
:这是
rootdir\\Makefile.toml
:
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]
This is rootdir\\frontend\\Cargo.toml
:这是
rootdir\\frontend\\Cargo.toml
:
[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-pack = "0.9.1"
wasm-bindgen = "0.2.68"
web-sys = "0.3.45"
[lib]
crate-type = ["cdylib", "rlib"]
This is rootdir\\frontend\\Makefile.toml
:这是
rootdir\\frontend\\Makefile.toml
:
[tasks.default]
dependencies = ["create_wasm"]
[tasks.create_wasm]
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["build"]
I expect the app to finish building with no errors when I run cargo make
.我希望应用程序在运行
cargo make
时能够完成构建并且没有错误。 The Yew tutorial seems to indicate nothing else is needed. Yew 教程似乎表明不需要其他任何东西。
I get a host of errors when running cargo make
(from the root directory) like the following:运行
cargo make
(从根目录)时出现许多错误,如下所示:
error[E0433]: failed to resolve: could not find `unix` in `os`
--> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\dirs-1.0.5\src\lin.rs:41:18
|
41 | use std::os::unix::ffi::OsStringExt;
| ^^^^ could not find `unix` in `os`
See the entire list of errors .查看完整的错误列表。
Is this a toolchain sort of thing?这是工具链之类的东西吗? How can I fix this?
我怎样才能解决这个问题?
rustup update
rustup update
I get the following output from running rustup update
.我从运行
rustup update
得到以下输出。
Now when I run cargo make
from the root directory, I get different errors:现在,当我从根目录运行
cargo make
时,出现不同的错误:
error[E0432]: unresolved import `crate::sys`
--> C:\Users\Zach\.cargo\registry\src\github.com-1ecc6299db9ec823\socket2-0.3.15\src\socket.rs:23:5
|
23 | use crate::sys;
| ^^^^^^^^^^ no `sys` in the root
See the full list of errors .查看完整的错误列表。 Some of the code changed in the repository .
存储库中的某些代码已更改。
The issue ended up being that I was trying to install wasm-pack
and web-sys
.问题最终是我试图安装
wasm-pack
和web-sys
。 I don't know why that was an issue but when I commented them out and ran cargo make
, everything built just fine.我不知道为什么这是一个问题,但是当我将它们注释掉并运行
cargo make
,一切都很好。 I also deleted target
and reran cargo make
just to make sure.我还删除了
target
并重新运行了cargo make
只是为了确保。
[package]
name = "frontend"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
sentinel = { path = ".." }
yew = "0.17.3"
wasm-bindgen = "0.2.68"
# wasm-pack = "0.9.1"
# web-sys = "0.3.45"
[lib]
crate-type = ["cdylib", "rlib"]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.