diff --git a/Cargo.toml b/Cargo.toml index e56aae3..8289325 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ rust-version = "1.74" license = "GPL-2.0-or-later" [dependencies.anyhow] -version = "1.0.46" +version = "1.0.77" [dependencies.camino] version = "1.1" diff --git a/src/main.rs b/src/main.rs index 85bdf36..8a7a0e8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,6 +6,14 @@ use std::process; fn main() { if let Err(e) = crun_vm::main(env::args_os().skip(1)) { eprintln!("{:#}", e); + + let rust_backtrace = env::var_os("RUST_BACKTRACE").unwrap_or_default(); + let rust_lib_backtrace = env::var_os("RUST_LIB_BACKTRACE").unwrap_or_default(); + + if (rust_backtrace == "1" || rust_lib_backtrace == "1") && rust_lib_backtrace != "0" { + eprintln!("\n{}\n", e.backtrace()); + } + process::exit(1); } } diff --git a/tests/env.sh b/tests/env.sh index 2999897..b838326 100755 --- a/tests/env.sh +++ b/tests/env.sh @@ -118,6 +118,8 @@ repo_root=$( readlink -e "$( dirname "$0" )/.." ) temp_dir=$( mktemp -d ) trap '__extra_cleanup; rm -fr "$temp_dir"' EXIT +export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1 + case "${1:-}" in build) if (( $# != 1 )); then @@ -383,7 +385,7 @@ run) TEMP_DIR=~/$label.temp UTIL_DIR=~/$label.util ENGINE=$engine - export RUST_BACKTRACE=${RUST_BACKTRACE:-1} + export RUST_BACKTRACE=1 RUST_LIB_BACKTRACE=1 $( cat "$t" )\ "