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

in v2.3.2 with wasm-client, it could not compile; error[E0432]: unresolved import http_client::isahc #345

Open
usagi opened this issue May 18, 2022 · 4 comments

Comments

@usagi
Copy link

usagi commented May 18, 2022

Repro

  1. cargo new surf-wasm-test --lib
  2. edit "Cargo.toml"
    • crate-type = [ "cdylib" ] in [lib]
    • surf = { version = "2.3.2", fefault-features = false, features = [ "wasm-client" ] } in [dependencies]
  3. cargo check --target wasm32-unknown-unknown, and then it occur the error.

Error

    Checking surf v2.3.2
error[E0432]: unresolved import `http_client::isahc`
  --> /home/usagi/.cargo/registry/src/github.com-1ecc6299db9ec823/surf-2.3.2/src/client.rs:13:26
   |
13 |         use http_client::isahc::IsahcClient as DefaultClient;
   |                          ^^^^^ could not find `isahc` in `http_client`

For more information about this error, try `rustc --explain E0432`.
error: could not compile `surf` due to previous error
@Fishrock123
Copy link
Member

Try building with default-features = false, features = ["h1-client"]

@usagi
Copy link
Author

usagi commented May 18, 2022

Oh, wasm-client is deprecated? Surely, cargo check and cargo test work as expected in surf/wasm-test if modified from wasm-client to h1-client. My problem has been solved thanks to #345 (comment) and I can now use the latest version of surf!

But, just in case, this Issue is maybe useful for wasm users who try to use surf newbies and hasn't used it in a long time. Should keep the issue until update the related documents and tests and examples? I will leave it to authors to decide when to close the issue.

Thank you! 💖

@Fishrock123
Copy link
Member

Honestly I wasn't really sure if that would work but cool to know that it did.

@KuTuGu
Copy link

KuTuGu commented Mar 1, 2023

Same version and configuration, but didn't work for me, on macOS.

Error:

error: the wasm32-unknown-unknown target is not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
   --> /Users/bytedance/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:263:9
    |
263 | /         compile_error!("the wasm32-unknown-unknown target is not supported by \
264 | |                         default, you may need to enable the \"js\" feature. \
265 | |                         For more information see: \
266 | |                         https://docs.rs/getrandom/#webassembly-support");
    | |________________________________________________________________________^

   Compiling foreign-types v0.3.2
   Compiling httparse v1.8.0
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> /Users/bytedance/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.8/src/lib.rs:290:5
    |
290 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Error: Compilation of your program failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: "cargo" "build" "--tests" "--target" "wasm32-unknown-unknown"

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

3 participants