human-panic icon indicating copy to clipboard operation
human-panic copied to clipboard

Determine rustc version and add it to the report

Open TheTechRobo opened this issue 1 year ago • 8 comments

This is a 🙋 feature.

Checklist

  • [x] tests pass
  • [ ] tests and/or benchmarks are included - is this necessary/possible for this?
  • [x] documentation is changed or added

Context

Fixes #31

Semver Changes

Major release - it changes the Report struct. I don't think 2.0 is released yet, so that would fit perfectly!

I have very little experience contributing to Rust crates, so if I made any mistakes, let me know!

TheTechRobo avatar Aug 18 '22 19:08 TheTechRobo

Cargo also sets the RUSTC env var to the path to rustc. cargo -vV may not match rustc -vV. Especially when using a locally built toolchain using rustup toolchain link as in that case the default cargo (which is probably an official version) will be combined with the local rustc which in most cases has a huge version skew.

bjorn3 avatar Aug 18 '22 19:08 bjorn3

Cargo also sets the RUSTC env var to the path to rustc.

Did not know that! I'll update that right now.

TheTechRobo avatar Aug 18 '22 19:08 TheTechRobo

@bjorn3 - getting this issue:

   Compiling human-panic v1.0.4-alpha.0 (/home/thetechrobo/human-panic)
error: environment variable `RUSTC` not defined
 --> /home/thetechrobo/human-panic/build.rs:6:22
  |
6 |     let cargo_path = env!("RUSTC");
  |                      ^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info)

error: could not compile `human-panic` due to previous error

I'm on nightly.

TheTechRobo avatar Aug 18 '22 19:08 TheTechRobo

You should use std::env::var("RUSTC").unwrap() instead. RUSTC is passed at runtime of the build script, but not at compile time.

bjorn3 avatar Aug 18 '22 19:08 bjorn3

@bjorn3 - All done.

TheTechRobo avatar Aug 18 '22 19:08 TheTechRobo

Should I rebase this PR, or are the maintainers fine with 7 (maybe more later if there's more review) commits?

TheTechRobo avatar Aug 18 '22 19:08 TheTechRobo

It probably won't hurt to squash. No idea what the maintainers prefer though.

bjorn3 avatar Aug 18 '22 19:08 bjorn3