From 34abb3c833711fde4db688e2a1b273fb0b70c877 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 27 Dec 2024 09:54:58 -0800 Subject: [PATCH 1/2] tools: fix `crowtty` cargo alias/just recipe (#344) PR #342 broke the `cargo crowtty` alias and `just crowtty` Just recipe. This is because we moved the `crowtty` binary out of the workspace's `default-packages`, so that CI builds don't require `libuv`. Because `crowtty` is no longer in `default-package`, running it using `cargo run` now requires passing --pacakge crowtty` as well as `--bin crowtty`, which the aliases don't do. This commit fixes that by adding `--package crowtty` to the `cargo crowtty` alias and the Just recipe. I also documented why crowtty isn't in `default-packages` in the Cargo.toml. --- .cargo/config.toml | 4 ++-- Cargo.toml | 4 ++++ justfile | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 524435b2..7d4c3809 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,5 +1,5 @@ [alias] -crowtty = "run --bin crowtty --release --" +crowtty = "run --package crowtty --bin crowtty --release --" melpomene = "run --bin melpomene --release --" melpo = "melpomene" forth3 = "run --bin f3repl --release --" @@ -23,7 +23,7 @@ runner = "cargo run --package mnemos-x86_64-bootimager -- --kernel-bin" # `rust-osdev/bootloader`, where a target crate depends on the kernel binary # artifact from the kernel core crate and links it with the bootloader binary in # a `build.rs` script. -# +# # Artifact dependencies are also used by `manganese` to depend on binary crates # as normal Cargo.toml dependencies. # diff --git a/Cargo.toml b/Cargo.toml index 252f877b..23c55217 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -49,6 +49,10 @@ default-members = [ # tools # note that this skips `manganese` by default, so that we don't build its # dependency features when running `cargo check --all-features` and similar. + # + # also, crowtty is excluded by default, as it depends on `libudev` on Linux, + # and we would like to be able to build documentation without having to + # install libudev on CI. "tools/libcrowtty", "tools/dumbloader", "tools/f3repl", diff --git a/justfile b/justfile index 8f28d7d7..46adc623 100644 --- a/justfile +++ b/justfile @@ -181,7 +181,7 @@ _x86-bootimager cmd *args='': # run crowtty (a host serial multiplexer, log viewer, and pseudo-keyboard) crowtty *FLAGS: - {{ _cargo }} run --profile {{ profile }} --bin crowtty -- {{ FLAGS }} + {{ _cargo }} run --package crowtty --profile {{ profile }} --bin crowtty -- {{ FLAGS }} # run the Melpomene simulator melpomene *FLAGS: From 6536ed750ce8d1dca182bb5cacc83519950c6f1e Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Fri, 27 Dec 2024 10:02:03 -0800 Subject: [PATCH 2/2] tools: enable fancy miette errors in `crowtty` (#345) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At some point (probably when `crowtty` was separated out into its own binary in #342), the `miette` dependency's `"fancy"` feature flag, which makes the debug print format for errors actually look nice and include cause chains, was eaten. This is a bummer, because having cause chains is important in order to understand the error message. This commit re-enables the `"fancy"` feature flag for `miette` in `crowtty`'s `Cargo.toml'. Prior to this change, errors looked like this: ```console eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.39s Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace` Error: Diagnostic { message: "failed to connect to /dev/ttyUSB1 (@ 115200)" } NOTE: If you're looking for the fancy error reports, install miette with the `fancy` feature, or write your own and hook it up with miette::set_hook(). ``` ...which I think we can all agree is not that useful. Now, the error looks like this: ```console eliza@theseus ~/Code/mnemos $ cargo run -p crowtty -- serial /dev/ttyUSB1 --verbose --trace trace Finished `dev` profile [unoptimized + debuginfo] target(s) in 6.22s Running `target/debug/crowtty serial /dev/ttyUSB1 --verbose --trace trace` Error: × failed to connect to /dev/ttyUSB1 (@ 115200) ╰─▶ Device or resource busy ``` This actually explains what went wrong, which seems good to me. --- tools/crowtty/Cargo.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/crowtty/Cargo.toml b/tools/crowtty/Cargo.toml index f3048423..30a97990 100644 --- a/tools/crowtty/Cargo.toml +++ b/tools/crowtty/Cargo.toml @@ -46,3 +46,4 @@ features = ["std"] [dependencies.miette] workspace = true +features = ["fancy"]