rust-embedded / discovery

Discover the world of microcontrollers through Rust!
https://docs.rust-embedded.org/discovery/
Apache License 2.0
1.46k stars 504 forks source link

probe-rs-tools installation fails #579

Open dyozie opened 1 month ago

dyozie commented 1 month ago

In Ubuntu, installing probe-rs-tools with cargo as indicated at https://github.com/rust-embedded/discovery/blob/71004431ef2ec0663f137a7a6262f8e5e1be458d/microbit/src/03-setup/README.md?plain=1#L72 fails with an error:

error[E0252]: the name FromBytes is defined multiple times

According to the latest probe-rs release notes, the toolkit should instead be installed via a shell/powershell script. https://github.com/probe-rs/probe-rs/releases has the relevant commands.

BartMassey commented 1 month ago

Thanks much for bringing this to our attention! That said, I'm not sure how to proceed.

It looks like the method for installing the probe-rs tools has again changed: we are now expected to download release binary tarballs from the probe-rs host and install them with a script. This seems to me not OK to recommend, at least without some clear explanation. The release notes refer me to the homepage or README, but I can't find any information there about this.

Current probe-rs-tools from top-of-tree master on their Git repo builds and installs fine. It looks like commit 6e975baf fixed the issue, but no release to crates.io has been made since then.

Several choices here: guidance appreciated:

BartMassey commented 1 month ago

Threw a bunch of stuff in the air. We'll see how it falls.

BartMassey commented 1 month ago

Turns out that cargo install --locked probe-rs-tools resolves the issue. Also turns out that the probe-rs folks don't want people to install using cargo install, for some reason I haven't yet determined.

dyozie commented 1 month ago

Thanks @BartMassey - just confirming that installing the locked version works for me on another system. That seems like the quickest/simplest fix for the tutorial. I'm not sure what the tradeoff would be for using the locked build vs the official installer.

BartMassey commented 1 month ago

The larger problem is that probe-rs apparently released 0.24.0 to crates.io "by mistake" and doesn't plan to release future versions in this way. I too don't understand what tradeoffs prompted this.

That said, I'm glad this worked for you and have a PR to adjust the Book accordingly. Thanks much.

spyoungtech commented 2 weeks ago

While this issue is open... it is also worth mentioning the guide also neglects to include installing Visual Studio, which is apparently required to compile probe-rs?

Even after installing cmake and putting in on PATH as described in the probe-rs prerequisites guide, I got the following error:

Error ``` --- stderr CMake Error at CMakeLists.txt:35 (project): Generator Visual Studio 17 2022 could not find any instance of Visual Studio. thread 'main' panicked at C:\Users\Spencer\.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5: ```

Although I have visual studio enterprise 2022 installed, this error persisted until I installed C++ cmake tools via visual studio.

After doing this, I tried installing per the current guide and got the same error[E0252]: the name FromBytes is defined multiple times error described in this issue.

I tried doing the cargo install --locked probe-rs-tools method, but that failed with the following error:

error[E0658] ``` error[E0658]: use of unstable library feature 'offset_of' --> C:\Users\Spencer\.cargo\registry\src\index.crates.io-6f17d22bba15001f\probe-rs-0.24.0\src\rtt\channel.rs:32:9 | 32 | std::mem::offset_of!(RttChannelBufferInner, write_offset) | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #106655 for more information error[E0658]: use of unstable library feature 'offset_of' --> C:\Users\Spencer\.cargo\registry\src\index.crates.io-6f17d22bba15001f\probe-rs-0.24.0\src\rtt\channel.rs:36:9 | 36 | std::mem::offset_of!(RttChannelBufferInner, read_offset) | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #106655 for more information error[E0658]: use of unstable library feature 'offset_of' --> C:\Users\Spencer\.cargo\registry\src\index.crates.io-6f17d22bba15001f\probe-rs-0.24.0\src\rtt\channel.rs:40:9 | 40 | std::mem::offset_of!(RttChannelBufferInner, flags) | ^^^^^^^^^^^^^^^^^^^ | = note: see issue #106655 for more information For more information about this error, try `rustc --explain E0658`. error: could not compile `probe-rs` (lib) due to 3 previous errors error: failed to compile `probe-rs-tools v0.24.0`, intermediate artifacts can be found at `C:\Users\Spencer\AppData\Local\Temp\cargo-installaT5YBr`. To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path. ```
spyoungtech commented 2 weeks ago

Circling back around to this, I was able to resolve this by upgrading rust from 1.76.0 to 1.80.1 -- then the --locked install worked.

The guide currently says Rust 1.57.0 or newer should work, but it seems like an even newer version of rust is actually needed to get probe-rs installed now.

jannic commented 2 weeks ago

It looks like offset_of! was stabilized in 1.77.0: https://releases.rs/docs/1.77.0/ (Usage of that macro was added in probe-rs v0.24.0)