fix: disable panic handler in ci (#8436)
### Description
When running in CI persisting the panic backtrace to a tempfile makes it
harder (or impossible) to get the entire backtrace.
This PR changes our behavior to no longer will persist the backtrace to
a file if we detect we're running in CI or a vendor, instead we include
the serialized backtrace in the message we print to the console.
First commit is moving the panic handler to the library crate to avoid
adding dependencies to the binary crate.
### Testing Instructions
```
[0 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ turbo_dev --version
Oops! Turbo has crashed.
A report has been written to /var/folders/3m/rxkycvgs5jgfvs0k9xcgp6km0000gn/T/report-319148de-342d-49f8-a87c-aa9c6d7b0cbd.toml
Please open an issue at https://github.com/vercel/turbo/issues/new/choose and include this file
[101 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ CI=1 turbo_dev --version
Oops! Turbo has crashed.
Caused by
"name" = "turbo"
"operating_system" = "Mac OS 14.4.1 [64-bit]"
"crate_version" = "2.0.4-canary.1"
"explanation" = """
file 'crates/turborepo/src/main.rs' at line 13
"""
"cause" = "Forced panic!"
"method" = "Panic"
"backtrace" = """
0: 0x100d22678 - core::panicking::panic_fmt::hc04a814f639f8411
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/panicking.rs:72
1: 0x100c78f30 - turbo[48bd35f77d4e47ef]::main
at /Users/olszewski/code/vercel/turborepo/crates/turborepo/src/main.rs:13
2: 0x100c78fc0 - <fn() -> core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error> as core[5c1d1104bc1ee810]::ops::function::FnOnce<()>>::call_once
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/ops/function.rs:250
3: 0x100c79198 - std[4e9c1a951f116da0]::sys_common::backtrace::__rust_begin_short_backtrace::<fn() -> core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>, core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/sys_common/backtrace.rs:155
4: 0x100c79114 - std[4e9c1a951f116da0]::rt::lang_start::<core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>::{closure#0}
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:159
5: 0x100d0233c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h0b62848974045da6
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/ops/function.rs:284
- std::panicking::try::do_call::h62aa855a2974a84f
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:559
- std::panicking::try::he4b3a2d91bf1dbbf
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:523
- std::panic::catch_unwind::h7420eceb348170da
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panic.rs:149
- std::rt::lang_start_internal::{{closure}}::h20b554397a83800b
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:141
- std::panicking::try::do_call::h4667a29b822d8c00
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:559
- std::panicking::try::h55eb6abb56c6f5e0
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:523
- std::panic::catch_unwind::he9dd44a8a626ad3d
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panic.rs:149
- std::rt::lang_start_internal::hacd033e6e2adb13b
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:141
6: 0x100c790e0 - std[4e9c1a951f116da0]::rt::lang_start::<core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:158
7: 0x100c78f54 - _main"""
Please open an issue at https://github.com/vercel/turbo/issues/new/choose and include this message in your issue
[101 olszewski@chriss-mbp] /Users/olszewski/code/vercel/turborepo $ GITHUB_ACTIONS=1 turbo_dev --version
Oops! Turbo has crashed.
Caused by
"name" = "turbo"
"operating_system" = "Mac OS 14.4.1 [64-bit]"
"crate_version" = "2.0.4-canary.1"
"explanation" = """
file 'crates/turborepo/src/main.rs' at line 13
"""
"cause" = "Forced panic!"
"method" = "Panic"
"backtrace" = """
0: 0x10254e678 - core::panicking::panic_fmt::hc04a814f639f8411
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/panicking.rs:72
1: 0x1024a4f30 - turbo[48bd35f77d4e47ef]::main
at /Users/olszewski/code/vercel/turborepo/crates/turborepo/src/main.rs:13
2: 0x1024a4fc0 - <fn() -> core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error> as core[5c1d1104bc1ee810]::ops::function::FnOnce<()>>::call_once
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/ops/function.rs:250
3: 0x1024a5198 - std[4e9c1a951f116da0]::sys_common::backtrace::__rust_begin_short_backtrace::<fn() -> core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>, core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/sys_common/backtrace.rs:155
4: 0x1024a5114 - std[4e9c1a951f116da0]::rt::lang_start::<core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>::{closure#0}
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:159
5: 0x10252e33c - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h0b62848974045da6
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/core/src/ops/function.rs:284
- std::panicking::try::do_call::h62aa855a2974a84f
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:559
- std::panicking::try::he4b3a2d91bf1dbbf
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:523
- std::panic::catch_unwind::h7420eceb348170da
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panic.rs:149
- std::rt::lang_start_internal::{{closure}}::h20b554397a83800b
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:141
- std::panicking::try::do_call::h4667a29b822d8c00
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:559
- std::panicking::try::h55eb6abb56c6f5e0
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panicking.rs:523
- std::panic::catch_unwind::he9dd44a8a626ad3d
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/panic.rs:149
- std::rt::lang_start_internal::hacd033e6e2adb13b
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:141
6: 0x1024a50e0 - std[4e9c1a951f116da0]::rt::lang_start::<core[5c1d1104bc1ee810]::result::Result<(), anyhow[ba69079c3fe1888b]::Error>>
at /rustc/6f3df08aadf71e8d4bf7e49f5dc10dfa6f254cb4/library/std/src/rt.rs:158
7: 0x1024a4f54 - _main"""
Please open an issue at https://github.com/vercel/turbo/issues/new/choose and include this message in your issue
```