Rust Backtrace on windows?
Asked Answered
A

4

20

I am trying to run my project https://github.com/comit-network/create-comit-app/ (master branch) on windows (I usually code on unix systems).

It panics but I am not able to get a backtrace despite settings RUST_BACKTRACE=1 or even RUST_BACKTRACE=full.

I am compiling and running on the same machine.

Here is what I get:

C:/Users/dante/.cargo/bin/cargo.exe run --color=always --package create-comit-app --bin create-comit-app --no-default-features -- start-env
   Compiling create-comit-app v0.5.0 (C:\Users\dante\src\create-comit-app)
    Finished dev [unoptimized + debuginfo] target(s) in 25.36s
     Running `target\debug\create-comit-app.exe start-env`
Panic received, cleaning up...Panic received, cleaning up...thread panicked while processing panic. aborting.
error: process didn't exit successfully: `target\debug\create-comit-app.exe start-env` (exit code: 0xc000001d, STATUS_ILLEGAL_INSTRUCTION)

Process finished with exit code -1073741795 (0xC000001D)

After some research it seems that it should be possible to get a BACKTRACE on windows?

I am coding and running on the same machine:

Rust: 1.39.0
>rustc --version
rustc 1.39.0 (4560ea788 2019-11-04)
>rustup toolchain list
stable-x86_64-pc-windows-msvc (default)
nightly-2019-04-30-x86_64-pc-windows-msvc
1.35.0-x86_64-pc-windows-msvc
1.37.0-x86_64-pc-windows-msvc
1.38.0-x86_64-pc-windows-msvc
1.39.0-x86_64-pc-windows-msvc

Also it looks like I cannot debug with -msvc toolchain and can only debug with -gnu. Trying to install the gnu chain now.

Anyone with windows experience in Rust?

Arietta answered 2/12, 2019 at 0:27 Comment(4)
Note that according to the message, you have two panics: one in your code, then one in the standard library when it tries to handle the first one → this second panic is probably the reason why you can't get a backtrace.It
What hardware are you using? Does a simple "hello world" (e.g. cargo new foo; cd foo; cargo run) work?It
Just in case: if you are using bash, you can use: export RUST_BACKTRACE=1. According to this reddit comment, if you're using cmd, it's: set RUST_BACKTRACE=1; if you're using powershell, it's $Env:RUST_BACKTRACE=1Educationist
@Educationist please note that in the link you provided, the OP's question says "and just using set RUST_BACKTRACE=1 does not help"Degraded
U
21

When using cmd, it's

set RUST_BACKTRACE=1
set RUST_BACKTRACE=full

when using powershell, it's

$env:RUST_BACKTRACE=1
$env:RUST_BACKTRACE="full"

e.g.

$env:RUST_BACKTRACE=1; cargo run

How do I run 'cargo test' with RUST_BACKTRACE=1 on Windows?

about Environment Variables - PowerShell | Microsoft Docs

set - cmd | Microsoft Docs

Udelle answered 17/6, 2021 at 8:41 Comment(0)
U
8

This works perfectly fine on windows -

$env:RUST_BACKTRACE=1; cargo run
Underscore answered 25/1, 2022 at 6:16 Comment(0)
B
8

If you don't want to bother with OS specific ways of setting an environment variable you can always configure it at your project's level and change it whenever you want.

Just create a .cargo/config.toml file at the root of your project and write this inside:

[env]
RUST_BACKTRACE = "1"

When you're done and want a less verbose compiler you can just set RUST_BACKTRACE="0"

Bethany answered 10/3, 2023 at 19:9 Comment(0)
A
0

Thank you for those attempting to help.

A colleague of mine was able to tackle down the panic issues.

Regarding backtrace, it was solved by changing the toolchain to ...-windows-gnu

Arietta answered 24/2, 2020 at 0:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.