Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot install with "cargo install c2rust" #1199

Open
omarandlorraine opened this issue Feb 7, 2025 · 5 comments
Open

Cannot install with "cargo install c2rust" #1199

omarandlorraine opened this issue Feb 7, 2025 · 5 comments

Comments

@omarandlorraine
Copy link

omarandlorraine commented Feb 7, 2025

I'm getting this error from doing cargo install c2rust, as it says in the README, or cargo install --locked c2rust.

The error is of course related to third-party libraries.

error[E0282]: type annotations needed for `Box<_>`
  --> /home/me/.cargo/registry/src/index.crates.io-6f17d22bba15001f/time-0.3.18/src/format_description/parse/mod.rs:83:9
   |
83 |     let items = format_items
   |         ^^^^^
...
86 |     Ok(items.into())
   |              ---- type must be known at this point
   |
   = note: this is an inference error on crate `time` caused by an API change in Rust 1.80.0; update `time` to version `>=0.3.35` by calling `cargo update`

For more information about this error, try `rustc --explain E0282`.
error: could not compile `time` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: failed to compile `c2rust v0.18.0`, intermediate artifacts can be found at `/tmp/cargo-installFxdDcD`.

It is worth noting that v 0.19.0 builds from source just fine, so I propose that the fix could be as simple as releasing this to crates.io, which is still on v 0.18.0.

Maybe it's related to issue #1196

@aario
Copy link

aario commented Feb 10, 2025

Me too. Tried also installing using --git but that also fails with another error.

$ cargo install --git https://github.com/immunant/c2rust.git c2rust
    Updating git repository `https://github.com/immunant/c2rust.git`
    Updating git submodule `https://github.com/codeplea/genann.git`
    Updating git submodule `https://github.com/immunant/grabc.git`
    Updating git submodule `https://github.com/immunant/libxml2-rs.git`
    Updating git submodule `https://github.com/immunant/lil.git`
    Updating git submodule `https://github.com/immunant/snudown.git`
    Updating git submodule `https://github.com/JordanMilne/gumbo-parser.git`
    Updating git submodule `https://github.com/html5lib/html5lib-tests.git`
    Updating git submodule `https://chromium.googlesource.com/external/googletest/`
    Updating git submodule `https://github.com/immunant/tinycc-rs.git`
    Updating git submodule `https://github.com/immunant/tmux-rs.git`
    Updating git submodule `https://github.com/jwerle/url.h.git`
    Updating git submodule `git://r-36.net/xzoom`
  Installing c2rust v0.19.0 (https://github.com/immunant/c2rust.git#3b1ec86b)
    Updating crates.io index
     Locking 135 packages to latest compatible versions
      Adding bindgen v0.65.1 (available: v0.71.1)
      Adding clap v3.2.25 (available: v4.5.28)
      Adding colored v2.2.0 (available: v3.0.0)
      Adding env_logger v0.10.2 (available: v0.11.6)
      Adding fern v0.6.2 (available: v0.7.1)
      Adding handlebars v4.5.0 (available: v6.3.1)
      Adding indexmap v1.9.3 (available: v2.7.1)
      Adding itertools v0.10.5 (available: v0.14.0)
      Adding prettyplease v0.1.25 (available: v0.2.29)
      Adding print_bytes v1.2.0 (available: v2.0.1)
      Adding strum v0.24.1 (available: v0.27.0)
      Adding strum_macros v0.24.3 (available: v0.27.0)
      Adding syn v1.0.109 (available: v2.0.98)
   Compiling proc-macro2 v1.0.93
   Compiling unicode-ident v1.0.16
   Compiling libc v0.2.169
   Compiling memchr v2.7.4
   Compiling syn v1.0.109
   Compiling serde v1.0.217
   Compiling thiserror v2.0.11
   Compiling glob v0.3.2
   Compiling prettyplease v0.2.29
   Compiling rustix v0.38.44
   Compiling clang-sys v1.8.1
   Compiling quote v1.0.38
   Compiling aho-corasick v1.1.3
   Compiling syn v2.0.98
   Compiling regex-syntax v0.8.5
   Compiling version_check v0.9.5
   Compiling minimal-lexical v0.2.1
   Compiling cfg-if v1.0.0
   Compiling linux-raw-sys v0.4.15
   Compiling bitflags v2.8.0
   Compiling shlex v1.3.0
   Compiling nom v7.1.3
   Compiling libloading v0.8.6
   Compiling regex-automata v0.4.9
   Compiling either v1.13.0
   Compiling log v0.4.25
   Compiling ucd-trie v0.1.7
   Compiling bindgen v0.65.1
   Compiling home v0.5.11
   Compiling which v4.4.2
   Compiling cexpr v0.6.0
   Compiling regex v1.11.1
   Compiling cc v1.2.13
   Compiling proc-macro-error-attr v1.0.4
   Compiling is-terminal v0.4.15
   Compiling peeking_take_while v0.1.2
   Compiling rustc-hash v1.1.0
   Compiling lazy_static v1.5.0
   Compiling bitflags v1.3.2
   Compiling autocfg v1.4.0
   Compiling lazycell v1.3.0
   Compiling termcolor v1.4.1
   Compiling once_cell v1.20.3
   Compiling object v0.36.7
   Compiling humantime v2.1.0
   Compiling print_bytes v1.2.0
   Compiling c2rust-build-paths v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-build-paths)
   Compiling indexmap v1.9.3
   Compiling env_logger v0.10.2
   Compiling cmake v0.1.54
   Compiling thiserror-impl v2.0.11
   Compiling proc-macro-error v1.0.4
   Compiling unicode-xid v0.2.6
   Compiling failure_derive v0.1.8
   Compiling prettyplease v0.1.25
   Compiling gimli v0.31.1
   Compiling thiserror v1.0.69
   Compiling heck v0.4.1
   Compiling serde_json v1.0.138
   Compiling adler2 v2.0.0
   Compiling rustversion v1.0.19
   Compiling miniz_oxide v0.8.3
   Compiling pest v2.7.15
   Compiling synstructure v0.12.6
   Compiling pest_meta v2.7.15
   Compiling addr2line v0.24.2
   Compiling thiserror-impl v1.0.69
   Compiling pest_generator v2.7.15
   Compiling serde_bytes v0.11.15
   Compiling ryu v1.0.19
   Compiling rustc-demangle v0.1.24
   Compiling half v1.8.3
   Compiling hashbrown v0.12.3
   Compiling c2rust-ast-exporter v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-ast-exporter)
   Compiling itoa v1.0.14
error: failed to run custom build command for `c2rust-ast-exporter v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-ast-exporter)`

Caused by:
  process didn't exit successfully: `/tmp/cargo-installlwUe9c/release/build/c2rust-ast-exporter-536a2888ec3cd0f8/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at c2rust-build-paths/src/lib.rs:88:44:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
error: failed to compile `c2rust v0.19.0 (https://github.com/immunant/c2rust.git#3b1ec86b)`, intermediate artifacts can be found at `/tmp/cargo-installlwUe9c`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

At this point I changed my mind on switch to rust. This language has a long way to go for its entire ecosystem to become stable.

@omarandlorraine
Copy link
Author

omarandlorraine commented Feb 10, 2025

At this point I changed my mind on switch to rust. This language has a long way to go for its entire ecosystem to become stable.

Please note that c2rust uses unstable Rust, don't throw the baby out with the bathwater. Stable Rust is way more stable, as it says on the tin.

@aario
Copy link

aario commented Feb 10, 2025

And here is with --git and with BACKTRACE enabled:

error: failed to run custom build command for `c2rust-ast-exporter v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-ast-exporter)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/tmp/cargo-installZT1vDg/release/build/c2rust-ast-exporter-536a2888ec3cd0f8/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at c2rust-build-paths/src/lib.rs:88:44:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  stack backtrace:
     0: rust_begin_unwind
     1: core::panicking::panic_fmt
     2: core::result::unwrap_failed
     3: c2rust_build_paths::find_llvm_config::{{closure}}::{{closure}}
     4: core::option::Option<T>::map
     5: c2rust_build_paths::find_llvm_config::{{closure}}
     6: core::option::Option<T>::or_else
     7: c2rust_build_paths::find_llvm_config
     8: build_script_build::LLVMInfo::new
     9: build_script_build::main
    10: core::ops::function::FnOnce::call_once
  note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
warning: build failed, waiting for other jobs to finish...
error: failed to compile `c2rust v0.19.0 (https://github.com/immunant/c2rust.git#3b1ec86b)`, intermediate artifacts can be found at `/tmp/cargo-installZT1vDg`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

@aario
Copy link

aario commented Feb 10, 2025

Ok. This is the last time I bother you. Sorry but this is the way rust shows error messages. Always a little bit more detail and some hint on how to beg for a little bit more!
Here the version of error with RUST_BACKTRACE=full

$ RUST_BACKTRACE=full cargo install --git https://github.com/immunant/c2rust.git c2rust
.
.
.
   Compiling c2rust-ast-exporter v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-ast-exporter)
   Compiling serde_cbor v0.11.2
error: failed to run custom build command for `c2rust-ast-exporter v0.19.0 (/home/aario/.cargo/git/checkouts/c2rust-2a3ef4c32beab81a/3b1ec86/c2rust-ast-exporter)`
note: To improve backtraces for build dependencies, set the CARGO_PROFILE_RELEASE_BUILD_OVERRIDE_DEBUG=true environment variable to enable debug information generation.

Caused by:
  process didn't exit successfully: `/tmp/cargo-installXw4J2z/release/build/c2rust-ast-exporter-536a2888ec3cd0f8/build-script-build` (exit status: 101)
  --- stderr
  thread 'main' panicked at c2rust-build-paths/src/lib.rs:88:44:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  stack backtrace:
     0:     0x56503ea3dfca - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::h4ef0e1453b64c27b
     1:     0x56503ea677a3 - core::fmt::write::h277b13fb184e2089
     2:     0x56503ea3a603 - std::io::Write::write_fmt::h799003400cfcaacb
     3:     0x56503ea3de12 - std::sys::backtrace::BacktraceLock::print::h6cc439abe141f88c
     4:     0x56503ea3efdc - std::panicking::default_hook::{{closure}}::h6c928662a2b2a8ee
     5:     0x56503ea3ee22 - std::panicking::default_hook::h466aa6f7ec573804
     6:     0x56503ea3f617 - std::panicking::rust_panic_with_hook::h0aa9cbd4f572f718
     7:     0x56503ea3f4aa - std::panicking::begin_panic_handler::{{closure}}::h40beb73db7d21c5f
     8:     0x56503ea3e4a9 - std::sys::backtrace::__rust_end_short_backtrace::h20a08e5b6c17bb0d
     9:     0x56503ea3f13c - rust_begin_unwind
    10:     0x56503ea65b90 - core::panicking::panic_fmt::hc4390fe0178a42ff
    11:     0x56503ea65f76 - core::result::unwrap_failed::h76c5e84f02aae1ea
    12:     0x56503ea14e25 - c2rust_build_paths::find_llvm_config::{{closure}}::{{closure}}::h94ece388cdfd39bc
    13:     0x56503ea13021 - core::option::Option<T>::map::h1f21cdc23927f230
    14:     0x56503ea14d35 - c2rust_build_paths::find_llvm_config::{{closure}}::h05dd44559f710f9f
    15:     0x56503ea1314f - core::option::Option<T>::or_else::h2142f658b43ce409
    16:     0x56503ea14cd4 - c2rust_build_paths::find_llvm_config::h7888c6ded956705c
    17:     0x56503e3bdf00 - build_script_build::LLVMInfo::new::h1e8eb148ce22321e
    18:     0x56503e3bba22 - build_script_build::main::hf49c8f700a4f62b5
    19:     0x56503e3b7063 - core::ops::function::FnOnce::call_once::h442a76f7e935b3aa
    20:     0x56503e3b6b66 - std::sys::backtrace::__rust_begin_short_backtrace::hf80e818e704c9505
    21:     0x56503e3b6ac9 - std::rt::lang_start::{{closure}}::hab28f76784c41d80
    22:     0x56503ea3568e - std::rt::lang_start_internal::h59c45ea516e664a8
    23:     0x56503e3b6aa7 - std::rt::lang_start::h2b91a7e46b58002f
    24:     0x56503e3bfc25 - main
    25:     0x7f68d3880ca8 - <unknown>
    26:     0x7f68d3880d65 - __libc_start_main
    27:     0x56503e3b6201 - _start
    28:                0x0 - <unknown>
warning: build failed, waiting for other jobs to finish...
error: failed to compile `c2rust v0.19.0 (https://github.com/immunant/c2rust.git#3b1ec86b)`, intermediate artifacts can be found at `/tmp/cargo-installXw4J2z`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

@anjx123
Copy link

anjx123 commented Feb 19, 2025

Ah I ran into this issue last week as well, the fix for me involved the following:

Changing my previous:
ENV LLVM_LIB_DIR=/usr/lib/llvm-11/lib ->
ENV LLVM_LIB_DIR=/usr/lib/llvm-10/lib

I found this solution after looking through the part of c2rust-build-paths that failed, and it seemed like it wasn't finding llvm properly. I where'd llvm and found that the version had changed it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants