简体   繁体   English

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

[英]WASM/Yew - failed to resolve: could not find `unix` in `os`

Building Yew App on Windows在 Windows 上构建 Yew 应用程序

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 子系统来构建应用程序,但我确实安装了它。

Code / Configuration代码/配置

The repository . 存储库

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"]

Expected result预期结果

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 教程似乎表明不需要其他任何东西。

Actual output实际产量

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?我怎样才能解决这个问题?

Running 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-packweb-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.

相关问题 Clang 针对 Windows 上的 WebAssembly(--target=wasm64) 找不到 C++ 标头 - Clang targeting WebAssembly(--target=wasm64) on Windows could not find C++ headers 找不到Windows命令将DOS文件转换为UNIX - Could Not find windows command to convert dos file to unix Blazor WASM Sophos [无法在资源的“完整性”属性中找到有效摘要] ERR_CERT_AUTHORITY_INVALID - Blazor WASM Sophos [Failed to find a valid digest in the 'integrity' attribute for resource] ERR_CERT_AUTHORITY_INVALID {中的错误:任务1失败-“找不到函数“ knn”” - Error in { : task 1 failed - “could not find function ”knn“” 应用程序无法启动,因为在“”中找不到 Qt 平台插件“Windows” - App failed to start because it could not find Qt platform plugin “Windows” in “” 如何解决“错误:无法找到或加载主 class FirstProgram”同时运行 OpenCV Java 在 Z323837578Z1969? - How to resolve “Error: Could not find or load main class FirstProgram” while running OpenCV Java in Eclipse? Windows 相当于 Unix 的“查找”命令? - Windows equivalent of Unix “find” command? 以编程方式检测共享驱动器是在UNIX还是Windows OS上 - Programmatically Detect whether share drive is on UNIX or Windows OS python os.walk 显示混合的 windows 和 unix 路径 - python os.walk displays mixed windows and unix paths 如何在Windows操作系统而不是`/ tmp` UNIX中存储文件? - How to store file in Windows OS instead of `/tmp` unix?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM