svartalf / rust-battery

Rust crate providing cross-platform information about the notebook batteries.
https://crates.io/crates/battery
Apache License 2.0
357 stars 40 forks source link

0.7.x does not build on FreeBSD #76

Closed bsdlme closed 3 years ago

bsdlme commented 3 years ago

I'm new to rustlang, so maybe it's a problem on my side. What I am seeing is that all battery crates from 0.7.x on do not build on my FreeBSD 12 system:

NomadBSD:/home/lars/dev/rust/battery% cargo init
     Created binary (application) package
NomadBSD:/home/lars/dev/rust/battery% echo 'battery = "0.7.7"' >> Cargo.toml 
NomadBSD:/home/lars/dev/rust/battery% cargo run
    Updating crates.io index
   Compiling autocfg v1.0.1
   Compiling typenum v1.12.0
   Compiling libc v0.2.80
   Compiling battery v0.7.7
   Compiling cfg-if v1.0.0
   Compiling num-traits v0.2.14
   Compiling uom v0.30.0
error[E0463]: can't find crate for `nix`
  --> /home/lars/.cargo/registry/src/github.com-1ecc6299db9ec823/battery-0.7.7/src/lib.rs:38:1
   |
38 | extern crate nix;
   | ^^^^^^^^^^^^^^^^^ can't find crate

error: aborting due to previous error

For more information about this error, try `rustc --explain E0463`.
error: could not compile `battery`.

To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed

Building version 0.6.0 works:

NomadBSD:/home/lars/dev/rust/battery% perl -i -p -e 's/0\.6\.0/0.6.2/' Cargo.toml
NomadBSD:/home/lars/dev/rust/battery% cargo run                                  
    Finished dev [unoptimized + debuginfo] target(s) in 0.06s
     Running `target/debug/battery`
Hello, world!
svartalf commented 3 years ago

Thanks for the bug report, @bsdlme!

It was accidentally broken in 2210de8b01de3963f21af8ff5a74d778b1dfa419 and fixed in 20233871e16b0e7083281df560875110a0cac93b. I also added Cirrus CI to ensure that FreeBSD compilation will work now all the time, so that should be it.

Fix was already published as a battery = "0.7.8", good luck with your hacking!