在Windows上构建紫杉应用
我正在构建一个紫杉树应用程序,同时在Windows上遵循this tutorial的火箭后端(尽管本教程是针对Linux环境的)。我正在尝试使用wasm-pack构建紫杉树应用程序。我没有使用Linux子系统来构建应用程序,尽管我已经安装了它。
代码/配置
我已经安装了wasm工具链和cargo make:
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\Cargo.toml
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"
[workspace]
members = ["backend", "frontend"]这是rootdir\Makefile.toml
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"
[tasks.default]
clear = true
dependencies = ["build"]这是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"]这是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"]预期结果
当我运行cargo make时,我希望应用程序可以完成构建而不会出现错误。Yew tutorial似乎表明不需要其他任何东西。
实际产出
在运行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 update
我通过运行rustup update获得了the following output。
现在,当我从根目录运行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请参阅full list of errors。其中一些代码更改了in the repository。
发布于 2020-10-02 11:57:14
问题最终是我试图安装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"]https://stackoverflow.com/questions/64164717
复制相似问题