How do i run a rust repl with RUST_BACKTRACE=1?
my rust program is panicking at an index out of bounds error, and I would like to see the backtrace for this, but I dont know how.
thread 'main' panicked at 'index out of bounds: the len is 19 but the index is 19', src/parser.rs:65:15
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
exit status 101
so how do I run with RUST_BACKTRACE=1?
.replit to include this information somewhere. If you can’t see it, click the three dots and “Show Hidden Files” in the Replit file browser.
I dont see anything involving environment variables in the .replit file, i tried running the program using
cargo run RUST_BACKTRACE=1 but it didnt change anything
I don’t know, but maybe setting a secret called “RUST_BACKTRACE” with a value of
1 would work? Those are environment variables.
Oh that did the trick, Thanks!
to make it work on forks of your repl, and make it clear that the env is being set, you could instead add it to the
env section of the
RUST_BACKTRACE = "1"
i get this error when i add that to the .replit file
unable to read .replit:
unable to decode .replit: toml: line 30 (last key "env.RUST_BACKTRACE"): incompatible types: TOML value has type int64; destination has type string
nix error: building nix env: problem reading '.replit' file: unable to decode .replit: toml: line 30 (last key "env.RUST_BACKTRACE"): incompatible types: TOML value has type int64; destination has type string
yeah, I had hit Reply too quickly. The
1 is meant to be quoted
oh yes that fixed it, thanks
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.