I have a rust project where i include the mysql-crate dependency and i want to have it os independent.
So i tried: Cargo.toml
[package]
name = "test"
version = "0.1.0"
authors = ["daMaex"]
[dependencies]
ws = "*"
clap = "*"
env_logger = "*"
[target.'cfg(any(unix, macos))'.dependencies.mysql]
version = "*"
default-features = false
features = ["socket"]
[target.'cfg(windows)'.dependencies.mysql]
version = "*"
default-features = false
features = ["pipe"]
[features]
default = []
ssl = []
The error already happens with a minimal main: src/main.rs
fn main () {
}
But the build fails. On macos/unix it always wants to compile the pipe and get's an unresolved import:
error[E0432]: unresolved import `std::os::windows::io::RawHandle`
--> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/named_pipe-0.2.2/src/lib.rs:38:5
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Could not find `windows` in `std::os`
and the same happens on Windows for the mysql crate itself:
error[E0432]: unresolved import `std::os::unix`
--> C:\Users\user\.cargo\registry\src\github.com-1ecc6299db9ec823\mysql-7.1.2\src\io.rs:24:5
|
24 | use std::os::unix as unix;
| ^^^^^^^^^^^^^^^^^^^^^ no `unix` in `std::os`
So my question is, how do i handle the OS-Dependency in this case?
This looks like a cargo
bug to me.
One related issue is Cannot declare different version of dependencies in mutually exclusive targets #3195
Edit: It is more of an unsupported feature than a bug according to the code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With