RUST_BACKTRACE=1 error (.../book/ch09-01) on win10

olo, rustafarians,

just sharing my experience for anyone experiencing same problem.
using windows10 64bit, and following rust book, in ch 09-01, when i follow the book's text, and try to use 'RUST_BACKTRACE=1', i get
''RUST_BACKTRACE' is not recognized as an internal or external command'.
searching the web revealed only a few answers, so i had to use good ol' 'trial&error' technique.
solution is:

  1. type into cmd: 'set RUST_BACKTRACE=1', confirm with [enter]
  2. then type 'cargo run'

now it works as expected, output is similar to book's example.
to disable BACKTRACE:

  1. type into cmd: 'set RUST_BACKTRACE=0'
    now 'cargo run' will output 'original' error messages.

godspeed,

simon
s love nia

You can also do

RUST_BACKTRACE=1 cargo run

To temporarily use backtrace for that run

Edit: didn't realize this was about cmd, so my post doesn't apply

If you're running this from cmd.exe you can't temporarily set an environment variable for a single command by starting the command with RUST_BACKTRACE=1. That's something specific to bash (and other *nix shells).

Instead you'll need to set the environment variable in a separate command:

$ set RUST_BACKTRACE 1
$ cargo run
1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.