WASM/Yew-解析失败:在操作系统中找不到“unix”` 在Windows上构建红豆杉应用程序
我正在Windows上与火箭后端一起构建一个红豆杉应用程序 (尽管本教程适用于Linux环境)。我正在尝试构建红豆杉应用程序 使用wasm包。不过,我没有使用Linux子系统来构建应用程序 我已经安装好了 代码/配置 我已经安装了wasm工具链和cargo make:WASM/Yew-解析失败:在操作系统中找不到“unix”` 在Windows上构建红豆杉应用程序,windows,rust,webassembly,yew,Windows,Rust,Webassembly,Yew,我正在Windows上与火箭后端一起构建一个红豆杉应用程序 (尽管本教程适用于Linux环境)。我正在尝试构建红豆杉应用程序 使用wasm包。不过,我没有使用Linux子系统来构建应用程序 我已经安装好了 代码/配置 我已经安装了wasm工具链和cargo make: rustup target add wasm32-unknown-unknown 以下是我的工具链列表: stable-x86_64-pc-windows-gnu stable-x86_64-pc-windows-msvc n
rustup target add wasm32-unknown-unknown
以下是我的工具链列表:
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
以下是我的文件夹结构:
Project root
├───backend <-- rocket backend
| ├───Cargo.toml
│ └───src
│ ├───bin
│ └───db
├───frontend <-- yew frontend
│ ├───pkg
│ ├───src
| ├───Cargo.toml
| └───Makefile.toml
├───src
├───Cargo.toml
└───Makefile.toml
这是rootdir\Makefile.toml
:
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]
[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"]
[tasks.default]
dependencies = ["create_wasm"]
[tasks.create_wasm]
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["build"]
这是rootdir\frontend\Cargo.toml
:
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]
[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"]
[tasks.default]
dependencies = ["create_wasm"]
[tasks.create_wasm]
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["build"]
这是rootdir\frontend\Makefile.toml
:
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]
[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"]
[tasks.default]
dependencies = ["create_wasm"]
[tasks.create_wasm]
command = "wasm-pack"
args = ["build", "--target", "web", "--out-name", "package", "--dev"]
dependencies = ["build"]
预期结果
我希望应用程序在运行时完成构建,不会出现任何错误
货物制造
。这个
似乎表明不需要其他东西
实际产量
当运行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`
看
这是一种工具链吗?我怎样才能解决这个问题
正在运行rustup更新
我明白了
从运行rustup update
现在,当我从根目录运行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
看。
一些代码发生了更改。问题在于我试图安装
wasm pack
和web sys
。我不知道为什么会出现这样的问题,但当我把它们注释掉并运行了《cargo make》时,一切都很好。我还删除了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"]
[软件包]
name=“前端”
version=“0.1.0”
作者=[“zachdelano”]
edition=“2018”
#请参阅上的更多关键点及其定义https://doc.rust-lang.org/cargo/reference/manifest.html
[依赖关系]
sentinel={path=“…”}
yew=“0.17.3”
wasm bindgen=“0.2.68”
#wasm pack=“0.9.1”
#web sys=“0.3.45”
[lib]
板条箱类型=[“cdylib”,“rlib”]