stanislav-tkach / os_info

Rust library to detect the operating system type
MIT License
175 stars 52 forks source link

3.8.0 broken on FreeBSD #370

Closed ydirson closed 8 months ago

ydirson commented 8 months ago

My CI picked up the new 3.8.0, and the FreeBSD jobs all fail:

  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.0/src/freebsd/mod.rs:11:19
   |
11 |     let version = uname()
   |                   ^^^^^-- an argument of type `&str` is missing
   |
note: function defined here
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.0/src/uname.rs:5:8
   |
5  | pub fn uname(arg: &str) -> Option<String> {
   |        ^^^^^ ---------
help: provide the argument
   |
11 |     let version = uname(/* &str */)
   |                        ~~~~~~~~~~~~
error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.0/src/freebsd/mod.rs:42:14
   |
40 |     match uname("-s") {
   |           ----------- this expression has type `Option<String>`
41 |         None => Type::Unknown,
42 |         Some("MidnightBSD") => Type::MidnightBSD,
   |              ^^^^^^^^^^^^^ expected `String`, found `&str`
error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.0/src/freebsd/mod.rs:43:14
   |
40 |     match uname("-s") {
   |           ----------- this expression has type `Option<String>`
...
43 |         Some("FreeBSD") => {
   |              ^^^^^^^^^ expected `String`, found `&str`
stanislav-tkach commented 8 months ago

Thank you for the report! Unfortunately, I have broken some things with the latest release. I will try to fix everything in the following patch.

tankf33der commented 8 months ago

I am on FreeBSD with os_info 3.8.1 and bug still here

...
...
   Compiling thrussh v0.34.0
   Compiling clap v4.5.3
   Compiling thrussh-config v0.6.0
   Compiling os_info v3.8.1
error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.1/src/freebsd/mod.rs:28:9
   |
27 |     match uname("-s").as_deref() {
   |           ---------------------- this expression has type `std::option::Option<&str>`
28 |         "MidnightBSD" => Type::MidnightBSD,
   |         ^^^^^^^^^^^^^ expected `Option<&str>`, found `&str`
   |
   = note:   expected enum `std::option::Option<&str>`
           found reference `&'static str`
help: try wrapping the pattern in `Some`
   |
28 |         Some("MidnightBSD") => Type::MidnightBSD,
   |         +++++             +

error[E0308]: mismatched types
  --> /root/.cargo/registry/src/index.crates.io-6f17d22bba15001f/os_info-3.8.1/src/freebsd/mod.rs:29:9
   |
27 |     match uname("-s").as_deref() {
   |           ---------------------- this expression has type `std::option::Option<&str>`
28 |         "MidnightBSD" => Type::MidnightBSD,
29 |         "FreeBSD" => {
   |         ^^^^^^^^^ expected `Option<&str>`, found `&str`
   |
   = note:   expected enum `std::option::Option<&str>`
           found reference `&'static str`
help: try wrapping the pattern in `Some`
   |
29 |         Some("FreeBSD") => {
   |         +++++         +

For more information about this error, try `rustc --explain E0308`.
error: could not compile `os_info` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
$
stanislav-tkach commented 8 months ago

@tankf33der Sorry for the inconvenience. I have published the 3.8.2 version and yanked both 3.8.0 and 3.8.1. I hope everything is OK now.

tankf33der commented 8 months ago

Works now, compiled ok. Issue closed.