首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WASM/Yew -无法解析:在`os`中找不到`unix`

WASM/Yew -无法解析:在`os`中找不到`unix`
EN

Stack Overflow用户
提问于 2020-10-02 08:14:04
回答 1查看 587关注 0票数 1

在Windows上构建紫杉应用

我正在构建一个紫杉树应用程序,同时在Windows上遵循this tutorial的火箭后端(尽管本教程是针对Linux环境的)。我正在尝试使用wasm-pack构建紫杉树应用程序。我没有使用Linux子系统来构建应用程序,尽管我已经安装了它。

代码/配置

The repository

我已经安装了wasm工具链和cargo make:

代码语言:javascript
复制
rustup target add wasm32-unknown-unknown

下面是我的工具链表:

代码语言:javascript
复制
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

下面是我的文件夹结构:

代码语言:javascript
复制
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

代码语言:javascript
复制
[package]
name = "sentinel"
version = "0.1.0"
authors = ["zachdelano <email>"]
edition = "2018"

[workspace]
members = ["backend", "frontend"]

这是rootdir\Makefile.toml

代码语言:javascript
复制
[env]
CARGO_MAKE_EXTEND_WORKSPACE_MAKEFILE = "true"

[tasks.default]
clear = true
dependencies = ["build"]

这是rootdir\frontend\Cargo.toml

代码语言:javascript
复制
[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

代码语言:javascript
复制
[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 (从根目录)时,我得到了一系列错误,如下所示:

代码语言:javascript
复制
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`

参见the entire list of errors

这是一种工具链类型的东西吗?我该如何解决这个问题呢?

运行rustup update

我通过运行rustup update获得了the following output

现在,当我从根目录运行cargo make时,我得到了不同的错误:

代码语言:javascript
复制
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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-10-02 11:57:14

问题最终是我试图安装wasm-packweb-sys。我不知道为什么这是一个问题,但当我将它们注释掉并运行cargo make时,一切都构建得很好。为了确认,我还删除了target并重新运行了cargo make

代码语言:javascript
复制
[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"]
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64164717

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档