Macchina-CLI / macchina

A system information frontend with an emphasis on performance.
https://crates.io/crates/macchina
MIT License
1.24k stars 47 forks source link

[BUG] Fails to build on Ubutnu #268

Closed yonas closed 1 year ago

yonas commented 1 year ago
$ cargo install macchina
    Updating crates.io index
  Downloaded macchina v6.1.5
  Downloaded 1 crate (62.7 KB) in 0.92s
  Installing macchina v6.1.5
error: failed to compile `macchina v6.1.5`, intermediate artifacts can be found at `/tmp/cargo-installADaNTG`

Caused by:
  failed to select a version for the requirement `libgit2-sys = "^0.13.4"`
  candidate versions found which didn't match: 0.13.2+1.4.2, 0.13.1+1.4.2, 0.13.0+1.4.1, ...
  location searched: crates.io index
  required by package `git2 v0.14.4`
      ... which satisfies dependency `git2 = "^0.14.4"` of package `vergen v7.4.2`
      ... which satisfies dependency `vergen = "^7.4.2"` of package `macchina v6.1.5`

OS: Ubuntu 22.04.1 LTS Kernel: Linux desktop 5.15.0-48-generic #54-Ubuntu SMP Fri Aug 26 13:26:29 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

grtcdr commented 1 year ago

I'm unable to reproduce this, have you managed to get around this?

Here's what I get:

image

yonas commented 1 year ago

No, I still get the same error with v6.1.6:

cargo install macchina
    Updating crates.io index
  Downloaded macchina v6.1.6
  Downloaded 1 crate (62.8 KB) in 0.76s
  Installing macchina v6.1.6
error: failed to compile `macchina v6.1.6`, intermediate artifacts can be found at `/tmp/cargo-install2TvcSA`

Caused by:
  failed to select a version for the requirement `libgit2-sys = "^0.13.4"`
  candidate versions found which didn't match: 0.13.2+1.4.2, 0.13.1+1.4.2, 0.13.0+1.4.1, ...
  location searched: crates.io index
  required by package `git2 v0.14.4`
      ... which satisfies dependency `git2 = "^0.14.4"` of package `vergen v7.4.2`
      ... which satisfies dependency `vergen = "^7.4.2"` of package `macchina v6.1.6`
yonas commented 1 year ago

I get a little further on Alpine 3.16.1:

...
   Compiling enum-iterator v1.1.3
   Compiling sysctl v0.4.6
   Compiling ansi-to-tui v2.0.0
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
  --> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/enum-iterator-1.1.3/src/lib.rs:82:26
   |
82 | pub const fn cardinality<T: Sequence>() -> usize {
   |                          ^
   |
   = note: see issue #93706 <https://github.com/rust-lang/rust/issues/93706> for more information

   Compiling clap v3.2.22
For more information about this error, try `rustc --explain E0658`.
error: could not compile `enum-iterator` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `macchina v6.1.6`, intermediate artifacts can be found at `/tmp/cargo-installBRTjnG`

Caused by:
  build failed
grtcdr commented 1 year ago

The build fails at different stages on different distributions. ansi-to-tui as far as I know doesn't suffer from any build issues, so it could be that your Rust version is slightly out of date. Could you try and update to the latest version?

yonas commented 1 year ago

I get the same error with rust 1.64.0:

$ ./snap/rustup/common/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo --version
cargo 1.64.0 (387270bc7 2022-09-16)

$ ./snap/rustup/common/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/rustc --version
rustc 1.64.0 (a55dd71d5 2022-09-19)
$ ./snap/rustup/common/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo install macchina
...
   Compiling ansi-to-tui v2.0.0
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
  --> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/enum-iterator-1.1.3/src/lib.rs:82:26
   |
82 | pub const fn cardinality<T: Sequence>() -> usize {
   |                          ^
   |
   = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information

For more information about this error, try `rustc --explain E0658`.
error: could not compile `enum-iterator` due to previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `macchina v6.1.6`, intermediate artifacts can be found at `/tmp/cargo-installoQPjep`
grtcdr commented 1 year ago

Couldn't find the relevant code snippet in ansi-to-tui, can you try installing again with --verbose?

yonas commented 1 year ago
$ ./snap/rustup/common/rustup/toolchains/stable-x86_64-unknown-linux-gnu/bin/cargo install --verbose macchina
...
   Compiling enum-iterator v1.1.3
     Running `rustc --crate-name enum_iterator --edition=2021 /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/enum-iterator-1.1.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=276c3230b7c5448d -C extra-filename=-276c3230b7c5448d --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern enum_iterator_derive=/tmp/cargo-installTzKcFL/release/deps/libenum_iterator_derive-90ff3a38ca2fdad8.so --cap-lints allow`
     Running `rustc --crate-name thiserror --edition=2018 /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/thiserror-1.0.37/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=99ebd48cab530a7a -C extra-filename=-99ebd48cab530a7a --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern thiserror_impl=/tmp/cargo-installTzKcFL/release/deps/libthiserror_impl-0db2cf33f2da7b47.so --cap-lints allow`
     Running `rustc --crate-name thiserror --edition=2018 /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/thiserror-1.0.37/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=1d0163612987af2c -C extra-filename=-1d0163612987af2c --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern thiserror_impl=/tmp/cargo-installTzKcFL/release/deps/libthiserror_impl-0db2cf33f2da7b47.so --cap-lints allow`
   Compiling sysctl v0.4.6
     Running `rustc --crate-name sysctl /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/sysctl-0.4.6/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=c06e51584f79548a -C extra-filename=-c06e51584f79548a --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern bitflags=/tmp/cargo-installTzKcFL/release/deps/libbitflags-39d29c794600078e.rmeta --extern byteorder=/tmp/cargo-installTzKcFL/release/deps/libbyteorder-b6e142b2b2e50c49.rmeta --extern libc=/tmp/cargo-installTzKcFL/release/deps/liblibc-5115f8d5d4def03a.rmeta --extern thiserror=/tmp/cargo-installTzKcFL/release/deps/libthiserror-1d0163612987af2c.rmeta --extern walkdir=/tmp/cargo-installTzKcFL/release/deps/libwalkdir-9e4f1ac4bde12e01.rmeta --cap-lints allow`
error[E0658]: trait bounds other than `Sized` on const fn parameters are unstable
  --> /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/enum-iterator-1.1.3/src/lib.rs:82:26
   |
82 | pub const fn cardinality<T: Sequence>() -> usize {
   |                          ^
   |
   = note: see issue #57563 <https://github.com/rust-lang/rust/issues/57563> for more information

   Compiling ansi-to-tui v2.0.0
     Running `rustc --crate-name ansi_to_tui --edition=2018 /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/ansi-to-tui-2.0.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C opt-level=3 -C linker-plugin-lto -C codegen-units=1 -C metadata=cca9cd8d1de59119 -C extra-filename=-cca9cd8d1de59119 --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern nom=/tmp/cargo-installTzKcFL/release/deps/libnom-1e8dddaf430703de.rmeta --extern thiserror=/tmp/cargo-installTzKcFL/release/deps/libthiserror-1d0163612987af2c.rmeta --extern tui=/tmp/cargo-installTzKcFL/release/deps/libtui-53e6bdc06a6a6793.rmeta --cap-lints allow`
For more information about this error, try `rustc --explain E0658`.
error: could not compile `enum-iterator` due to previous error

Caused by:
  process didn't exit successfully: `rustc --crate-name enum_iterator --edition=2021 /home/yonas/.cargo/registry/src/github.com-1ecc6299db9ec823/enum-iterator-1.1.3/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debug-assertions=off -C metadata=276c3230b7c5448d -C extra-filename=-276c3230b7c5448d --out-dir /tmp/cargo-installTzKcFL/release/deps -L dependency=/tmp/cargo-installTzKcFL/release/deps --extern enum_iterator_derive=/tmp/cargo-installTzKcFL/release/deps/libenum_iterator_derive-90ff3a38ca2fdad8.so --cap-lints allow` (exit status: 1)
warning: build failed, waiting for other jobs to finish...
error: failed to compile `macchina v6.1.6`, intermediate artifacts can be found at `/tmp/cargo-installTzKcFL`
grtcdr commented 1 year ago

It is indeed enum-iterator that's causing this, I'll have a look at their GitHub issues to see if something's up.

UPDATE: Looks like there is an open issue for this, but I don't understand why it affects you given you're on the most recent version. I suggest reporting this occurrence there instead, as I can't do much about this personally.

stephaneyfx commented 1 year ago

Despite what /full/path/rustc --version returns, it looks like the code is not built with Rust 1.64.0. I have no experience with Rust installed through snap. Is it possible that you have Rust installed somewhere else too and that gets picked up when running cargo install? What is the output of the following commands?

rustup show
/full/path/to/snap/installed/rustup show
yonas commented 1 year ago
$ rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/yonas/snap/rustup/common/rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.64.0 (a55dd71d5 2022-09-19)

$ /snap/bin/rustup show
Default host: x86_64-unknown-linux-gnu
rustup home:  /home/yonas/snap/rustup/common/rustup

stable-x86_64-unknown-linux-gnu (default)
rustc 1.64.0 (a55dd71d5 2022-09-19)
stephaneyfx commented 1 year ago

What about this?

which rustc
which cargo
yonas commented 1 year ago
$ which rustc
/usr/bin/rustc

$ which cargo
/usr/bin/cargo
stephaneyfx commented 1 year ago

Thank you. What is the output of this?

/usr/bin/rustc --version
stephaneyfx commented 1 year ago

If this outputs an older version, my guess is that /path/to/snap/installed/cargo install ... ends up invoking /usr/bin/rustc. You should probably use your distro package manager to uninstall Rust if you want to use Rust from snap.

grtcdr commented 1 year ago

You should probably use your distro package manager to uninstall Rust if you want to use Rust from snap.

I absolutely agree, but I'm interested to know why they have two Rust compilers installed.

yonas commented 1 year ago

@stephaneyfx

$ /usr/bin/rustc --version
rustc 1.61.0
yonas commented 1 year ago

I absolutely agree, but I'm interested to know why they have two Rust compilers installed.

I'm not sure either...

grtcdr commented 1 year ago

I'm not sure either...

Then I'd recommend uninstalling either one of them.

EDIT: Looks like the Rust compiler you installed through apt is out of date, I suggest upgrading it to a later version, or uninstall it and use the one provided by snap since it's up to date.

Another option is to set the build.rustc option to a path other than /usr/bin/rustc in your $CARGO_HOME/config.toml if $CARGO_HOME is set or $HOME/.cargo/config.toml if not.

This document explains this process quite well, but in short you should create the aforementioned document if it doesn't exist by running:

touch ~/.cargo/config.toml

And then execute:

echo "[build]\nrustc = "/snap/bin/rustup" > ~/.cargo/config.toml

cargo will by default call rustc which expands to the absolute path shown by executing which rustc, in your case that's /usr/bin/rustc which is a little too old to compile macchina.

yonas commented 1 year ago

Thanks, that worked! :partying_face:

Small typo - rustc should point to /snap/bin/rustc

[build]
rustc = "/snap/bin/rustc"