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

error[E0583]: file not found for module sys #35

Closed
justinmchase opened this issue Jul 5, 2019 · 23 comments
Closed

error[E0583]: file not found for module sys #35

justinmchase opened this issue Jul 5, 2019 · 23 comments

Comments

@justinmchase
Copy link

I'm trying to build using wasm-pack build and its giving me this error:

    Compiling socket2 v0.3.9

error[E0583]: file not found for module `sys`
  --> /home/justin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/socket2-0.3.9/src/lib.rs:72:5
   |
72 | mod sys;
   |     ^^^
   |
   = help: name the file either sys.rs or sys/mod.rs inside the directory "/home/justin/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/socket2-0.3.9/src"

I'm very new at this but it seems like its pulling down the latest version of the code in this repo and failing to compile.

Any help would be greatly appreciated.

@justinmchase
Copy link
Author

This line appears to vary from master:
https://github.com/alexcrichton/socket2-rs/blob/ca89d63b87f4ec62f059caa1d9379c0dc8f1cd2b/src/lib.rs#L72

When I do a simple cfg check in my own app it appears to be resolved as "unix" so I'm not sure why this is failing.

Any workarounds welcome.

@alexcrichton
Copy link
Member

Thanks for the report! This crate needs to add some stubs for the wasm target that all return errors, but otherwise shouldn't be too hard to add.

@murtyjones
Copy link

murtyjones commented Jul 14, 2019

I'm getting this error too in a project of my own, and it's kind of mysterious because it seemed to come out of nowhere and when I run wasm-pack build in other projects, it works.

this person seems to have found a workaround but I couldn't figure out what it was.

@justinmchase did you find a workaround?

@justinmchase
Copy link
Author

I was not able to other than to not use the library that depended on this. I looked at it for a while and I bet there is a way but I'm not familiar enough with Rust to figure it out yet.

For what it's worth I was using WSL on windows but after a bunch of tests it seems like Rust correctly interprets it as unix and there wasn't a problem with the conditional compilation macros in smaller independent tests.

@ghost
Copy link

ghost commented Apr 25, 2020

I think I am getting a similar error. I'm using a library that depends on socket for a WASM project.

error[E0432]: unresolved import crate::sys --> C:\Users\Thomas\.cargo\registry\src\git.luolix.top-1ecc6299db9ec823\socket2-0.3.12\src\socket.rs:23:5
|
23 | use crate::sys;
| ^^^^^^^^^^ no sys in the root

@twitchax
Copy link

As far as I can tell, this is still an issue. socket2 fails to compile on wasm becaause the sys module is only imported for a unix or windows target.

@Thomasdezeeuw
Copy link
Collaborator

@twitchax that's because wasm isn't supported.

@twitchax
Copy link

@Thomasdezeeuw, I was mostly commenting because this issue was closed without explanation. That would have been a helpful note to people who come across this issue. :)

@Thomasdezeeuw
Copy link
Collaborator

@Thomasdezeeuw, I was mostly commenting because this issue was closed without explanation. That would have been a helpful note to people who come across this issue. :)

To be fair the issuer closed it, not the maintainers but I understand. We should probably add a compile_error for unsupported targets to make it clear from the error message.

@justinmchase
Copy link
Author

Sorry, I think I just closed it because I didn't want to see it in my list of open issues anymore and nobody seemed to care about it.

@justinmchase justinmchase reopened this Sep 17, 2021
@twitchax
Copy link

@justinmchase, haha, no problem.

I think it is still something that would be nice. There are a lot of projects that rely on socket2 that cannot be used in wasm targets due to the lack of support here. For example, I am testing how feasible it would be to use a project like warp or rocket in Rust-based CloudFlare Workers.

@damirka
Copy link

damirka commented Sep 20, 2021

Can confirm that it is an issue for some (if not many) people. I wonder if there is a way to nicely disable or put a placeholder for unsupported targets, so this functionality is disabled, but not blocking compilation of other crates. 🤔

@Thomasdezeeuw
Copy link
Collaborator

I'm closing this in favour of #268 to track wasm support.

@Neo-Ciber94
Copy link

Neo-Ciber94 commented Aug 9, 2022

I ended using something like this, it works but in others cases it fails not sure why

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
tokio = { version = "1", features = ["full"] }
async-trait = "0.1.57"
actix-web = "4"
stdweb = "0.4.20"

@PDFergus
Copy link

@justinmchase, haha, no problem.

I think it is still something that would be nice. There are a lot of projects that rely on socket2 that cannot be used in wasm targets due to the lack of support here. For example, I am testing how feasible it would be to use a project like warp or rocket in Rust-based CloudFlare Workers.

Yeah I just found out by nasty Surprise after integrating my Database calls to the front end only to find out that although the queries are crafted correctly that the database structure I am using may in fact use Socket2 nested deep down in its dependency structure, specifically in the aws_auth_sdk. So if you are using any data from an amazon authenticated source, you may be at the migration point.

oh well back to the drawing board I guess. Maybe I will give SurealDB a shot.

@NazarKhlopeniuk
Copy link

I have the same issue.
How can I handle this?

@Thomasdezeeuw
Copy link
Collaborator

I have the same issue. How can I handle this?

@NazarKhlopeniuk what platform are you using? If you're using wasm you can help in #268.

@NazarKhlopeniuk
Copy link

windows 10 64bit.

@NazarKhlopeniuk
Copy link

image

@NazarKhlopeniuk
Copy link

This is the error that I get after running "cargo test"

@Thomasdezeeuw
Copy link
Collaborator

Please don't post text as a image, you can put multiple lines line that between "```" to create a code block, see https://docs.github.com/en/get-started/writing-on-github/working-with-advanced-formatting/creating-and-highlighting-code-blocks.

The error shown in image seems related to wasm/axum, not Socket2. But if you're pulling in socket2 I'm sorry to say that it won't work for now as we don't support wasm, see #268.

@Tahmid-Hossen
Copy link

I am getting this error while run wasm-pack build. Anyone assist me to fix it

[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling wasm-bindgen-backend v0.2.92
Compiling serde_derive v1.0.197
Compiling inout v0.1.3
Compiling cipher v0.3.0
Compiling url v2.5.0
Compiling sha1_smol v1.0.0
Compiling socket2 v0.4.10
Compiling base64 v0.20.0
error[E0583]: file not found for module sys
--> C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\lib.rs:124:1
|
124 | mod sys;
| ^^^^^^^^
|
= help: to create the module sys, create file "C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\sys.rs" or "C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\sys\mod.rs"
= note: if there is a mod sys elsewhere in the crate already, import it with use crate::... instead

error: Socket2 doesn't support the compile target
--> C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\lib.rs:127:1
|
127 | compile_error!("Socket2 doesn't support the compile target");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0432]: unresolved imports crate::sys::sa_family_t, crate::sys::sockaddr, crate::sys::sockaddr_in, crate::sys::sockaddr_in6, crate::sys::sockaddr_storage, crate::sys::socklen_t, crate::sys::AF_INET, crate::sys::AF_INET6
--> C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\sockaddr.rs:6:5
|
6 | sa_family_t, sockaddr, sockaddr_in, sockaddr_in6, sockaddr_storage, socklen_t, AF_INET,
| ^^^^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^ ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^ no AF_INET in sys
| | | | | | |
| | | | | | no socklen_t in sys
| | | | | no sockaddr_storage in sys
| | | | no sockaddr_in6 in sys
| | | no sockaddr_in in sys
| | no sockaddr in sys
| no sa_family_t in sys
7 | AF_INET6,
| ^^^^^^^^ no AF_INET6 in sys
|
= help: consider importing this module instead:
crate::sockaddr

error[E0432]: unresolved imports crate::sys::c_int, crate::sys::getsockopt, crate::sys::setsockopt, crate::sys::Bool
--> C:\Users\aryan.cargo\registry\src\index.crates.io-6f17d22bba15001f\socket2-0.4.10\src\socket.rs:23:24
|
23 | use crate::sys::{self, c_int, getsockopt, setsockopt, Bool};

@Thomasdezeeuw
Copy link
Collaborator

@Tahmid-Hossen WASM is not supported, see #268.

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

10 participants