knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
646 stars 75 forks source link

cargo install probe-run fails with compilation error #347

Closed tolgaparlan closed 2 years ago

tolgaparlan commented 2 years ago

Describe the bug Simply running cargo install probe-run ends up with

   Compiling defmt-json-schema v0.1.0
   Compiling probe-rs-target v0.13.0
   Compiling defmt-decoder v0.3.3
error[E0716]: temporary value dropped while borrowed
  --> /Users/tolgaparlan/.cargo/registry/src/github.com-1ecc6299db9ec823/defmt-decoder-0.3.3/src/log/json_logger.rs:26:28
   |
26 |             let mut sink = io::stdout().lock();
   |                            ^^^^^^^^^^^^       - temporary value is freed at the end of this statement
   |                            |
   |                            creates a temporary which is freed while still in use
...
29 |             serde_json::to_writer(&mut sink, &create_json_frame(record, host_timestamp)).ok();
   |                                   --------- borrow later used here
   |
   = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
  --> /Users/tolgaparlan/.cargo/registry/src/github.com-1ecc6299db9ec823/defmt-decoder-0.3.3/src/log/json_logger.rs:33:24
   |
33 |             let sink = io::stderr().lock();
   |                        ^^^^^^^^^^^^       - temporary value is freed at the end of this statement
   |                        |
   |                        creates a temporary which is freed while still in use
34 |             self.host_logger.print_host_record(record, sink);
   |                                                        ---- borrow later used here
   |
   = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
  --> /Users/tolgaparlan/.cargo/registry/src/github.com-1ecc6299db9ec823/defmt-decoder-0.3.3/src/log/json_logger.rs:50:24
   |
50 |         let mut sink = io::stdout().lock();
   |                        ^^^^^^^^^^^^       - temporary value is freed at the end of this statement
   |                        |
   |                        creates a temporary which is freed while still in use
51 |         serde_json::to_writer(&mut sink, &SCHEMA_VERSION).ok();
   |                               --------- borrow later used here
   |
   = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
  --> /Users/tolgaparlan/.cargo/registry/src/github.com-1ecc6299db9ec823/defmt-decoder-0.3.3/src/log/pretty_logger.rs:34:28
   |
34 |                 let sink = io::stdout().lock();
   |                            ^^^^^^^^^^^^       - temporary value is freed at the end of this statement
   |                            |
   |                            creates a temporary which is freed while still in use
...
38 |                     None => Self::print_println_record(record, sink),
   |                                                                ---- borrow later used here
   |
   = note: consider using a `let` binding to create a longer lived value

error[E0716]: temporary value dropped while borrowed
  --> /Users/tolgaparlan/.cargo/registry/src/github.com-1ecc6299db9ec823/defmt-decoder-0.3.3/src/log/pretty_logger.rs:43:28
   |
43 |                 let sink = io::stderr().lock();
   |                            ^^^^^^^^^^^^       - temporary value is freed at the end of this statement
   |                            |
   |                            creates a temporary which is freed while still in use
44 |                 self.print_host_record(record, sink);
   |                                                ---- borrow later used here
   |
   = note: consider using a `let` binding to create a longer lived value

For more information about this error, try `rustc --explain E0716`.
error: could not compile `defmt-decoder` due to 5 previous errors
warning: build failed, waiting for other jobs to finish...
error: failed to compile `probe-run v0.3.4`, intermediate artifacts can be found at `/var/folders/9l/m7lkb4vx10s3s3g0dq086s3m0000gn/T/cargo-installVSUMIJ`

Caused by:
  build failed

To Reproduce Steps to reproduce the behavior: I am in an m1-mac environment. Other than that I don't think I had to do anything special to reach this bug.

jonas-schievink commented 2 years ago

Your Rust version is out of date and needs to be updated

Urhengulas commented 2 years ago

Hi @tolgaparlan, as Jonas said you need to update Rust to at least 1.61, which introduced "static handles for locked stdio". Read more about it here: https://blog.rust-lang.org/2022/05/19/Rust-1.61.0.html#static-handles-for-locked-stdio.

To update just run

$ rustup update