Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project using it fail to be compiled to wasm #94

Closed
CNCSMonster opened this issue Jun 26, 2024 · 4 comments
Closed

Project using it fail to be compiled to wasm #94

CNCSMonster opened this issue Jun 26, 2024 · 4 comments

Comments

@CNCSMonster
Copy link

To rehappen

i first execute following order

cargo new try-which --lib
cd try-which

write src/lib.rs as below

pub fn try_which(){
    which::which("gcc").unwrap();
}

write Cargo.toml as below

[package]
name = "path-labs"
version = "0.1.0"
edition = "2021"
[lib]
crate-type = ["cdylib", "rlib"]
[dependencies]
which = "6.0.1"

then i try build it to wasm as below:

wasm-pack build . --target nodejs -- --no-default-features

but instead of sussess, i get error as below:

   Compiling which v6.0.1
error[E0046]: not all trait items implemented, missing: `is_valid`
  --> /home/cncsmonster/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/which-6.0.1/src/checker.rs:13:1
   |
13 | impl Checker for ExecutableChecker {
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `is_valid` in implementation
   |
  ::: /home/cncsmonster/.cargo/registry/src/rsproxy.cn-0dccff568467c15b/which-6.0.1/src/finder.rs:28:5
   |
28 |     fn is_valid(&self, path: &Path) -> bool;
   |     ---------------------------------------- `is_valid` from trait

For more information about this error, try `rustc --explain E0046`.
error: could not compile `which` (lib) due to 1 previous error
Error: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "." && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown" "--no-default-features"

ENV

$ uname -a
Linux DESKTOP-NGIRL25 5.15.153.1-microsoft-standard-WSL2 #1 SMP Fri Mar 29 23:14:13 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release 
PRETTY_NAME="Ubuntu 22.04.4 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.4 LTS (Jammy Jellyfish)"
VERSION_CODENAME=jammy
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=jammyu
@Xaeroxe
Copy link
Collaborator

Xaeroxe commented Jun 26, 2024

wasm32-unknown-unknown is not a supported target, however wasm32-wasi and other wasi variants are supported.

@Xaeroxe
Copy link
Collaborator

Xaeroxe commented Jun 26, 2024

Here's more info on wasm32-wasi and wasm-pack rustwasm/wasm-pack#654

@Xaeroxe
Copy link
Collaborator

Xaeroxe commented Jun 26, 2024

Consider using this tool instead: https://github.com/bytecodealliance/cargo-wasi

@Xaeroxe
Copy link
Collaborator

Xaeroxe commented Jun 26, 2024

I must also make it clear that it's not possible for this project to support wasm without wasi. You need a filesystem in order to search a filesystem, and wasm without wasi doesn't have a filesystem.

@Xaeroxe Xaeroxe closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants