prisma / tiberius

TDS 7.2+ (Microsoft SQL Server) driver for Rust
Apache License 2.0
327 stars 119 forks source link

Build error cross compiling from macOS to Windows #293

Closed yatesco closed 1 year ago

yatesco commented 1 year ago

Hi there. I'm using Tiberius:

tiberius = { version = "0.12", default-features = false, features = ["chrono", "tokio", "rustls", "integrated-auth-gssapi"] }

to cross compile from macOS to Windows:

cargo build --target x86_64-pc-windows-gnu --release

and getting the following error:

error[E0599]: no variant or associated item named `Integrated` found for enum `AuthMethod` in the current scope
   --> /Users/coliny/.cargo/registry/src/github.com-1ecc6299db9ec823/tiberius-0.12.2/src/client/config.rs:303:32
    |
303 |                 Ok(AuthMethod::Integrated)
    |                                ^^^^^^^^^^ variant or associated item not found in `AuthMethod`
    |
   ::: /Users/coliny/.cargo/registry/src/github.com-1ecc6299db9ec823/tiberius-0.12.2/src/client/auth.rs:51:1
    |
51  | pub enum AuthMethod {
    | ------------------- variant or associated item `Integrated` not found for this enum

For more information about this error, try `rustc --explain E0599`.
error: could not compile `tiberius` due to previous error

I'm not really clear on why Integrated cannot be used on Windows (particularly as this is exactly the use case I'm trying to implement!), so I thought I'd stop and ask for help :-).

willbush commented 1 year ago

I ran into the same issue.

https://github.com/prisma/tiberius/blob/main/src/client/auth.rs#L61 https://github.com/prisma/tiberius/blob/main/Cargo.toml#L56

Looks like winauth feature is needed in windows.

Here's how I fixed it based on this:

[target.'cfg(unix)'.dependencies]
tiberius = { version = "0.12", default-features = false, features = ["tds73", "sql-browser-tokio", "integrated-auth-gssapi", "time"] }

[target.'cfg(windows)'.dependencies]
tiberius = { version = "0.12", default-features = false, features = ["tds73", "sql-browser-tokio", "winauth", "time"] }
yatesco commented 1 year ago

(closing thanks to @willbush's comment https://github.com/prisma/tiberius/issues/293#issuecomment-1585196262)