From d83887106378dfd1d77e94c4a51242f42ea336f3 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Sun, 5 Nov 2023 17:19:06 -0600 Subject: [PATCH] add color-backtrace crate for more intuitive backtraces (#10942) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Just throwing up this PR because color-backtrace seemed to produce more useful backtraces. Just curious what others think. Did this: 1. RUST_BACKTRACE=full cargo r 2. ❯ def test01 [] { let sorted = [storm] $sorted | range 1.. | zip ($sorted | range ..(-2)) } 3. test01 I like how it shows the code snippet. ![image](https://github.com/nushell/nushell/assets/343840/1302e766-dfac-4749-a465-85bf53060532) # User-Facing Changes # Tests + Formatting # After Submitting --- Cargo.lock | 11 +++++++++++ Cargo.toml | 1 + src/main.rs | 3 +++ 3 files changed, 15 insertions(+) diff --git a/Cargo.lock b/Cargo.lock index a3d42de404..62c679a210 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -697,6 +697,16 @@ dependencies = [ "encoding_rs", ] +[[package]] +name = "color-backtrace" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "150fd80a270c0671379f388c8204deb6a746bb4eac8a6c03fe2460b2c0127ea0" +dependencies = [ + "backtrace", + "termcolor", +] + [[package]] name = "colorchoice" version = "1.0.0" @@ -2648,6 +2658,7 @@ name = "nu" version = "0.86.1" dependencies = [ "assert_cmd", + "color-backtrace", "criterion", "crossterm 0.27.0", "ctrlc", diff --git a/Cargo.toml b/Cargo.toml index 92a54243eb..75031899e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -71,6 +71,7 @@ nu-utils = { path = "./crates/nu-utils", version = "0.86.1" } nu-ansi-term = "0.49.0" reedline = { version = "0.25.0", features = ["bashisms", "sqlite"] } +color-backtrace = "0.6.1" crossterm = "0.27" ctrlc = "3.4" log = "0.4" diff --git a/src/main.rs b/src/main.rs index ce0b4c024e..0040707ecd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,6 +59,9 @@ fn main() -> Result<()> { miette_hook(x); })); + // This allows more intuitive backtraces + color_backtrace::install(); + // Get initial current working directory. let init_cwd = get_init_cwd(); let mut engine_state = get_engine_state();