Skip to content

refactor: drop stale and redundant dependencies#199

Merged
inureyes merged 1 commit into
mainfrom
refactor/drop-stale-deps
May 11, 2026
Merged

refactor: drop stale and redundant dependencies#199
inureyes merged 1 commit into
mainfrom
refactor/drop-stale-deps

Conversation

@inureyes
Copy link
Copy Markdown
Member

Summary

Audit the full direct dependency set in Cargo.toml, then remove or replace crates that were dead, redundant with the standard library, or duplicated with an existing dependency.

Build graph wins

  • Fully removed: arrayvec, ctrlc (+ macOS objc2/block2/dispatch2 chain it pulled in), directories, signal-hook 0.4.4.
  • No longer in our direct deps (still transitive from other crates): lazy_static, once_cell, fastrand.
  • Cargo.lock shrinks by 76 lines.

Replacements

Crate Replacement Sites
lazy_static! std::sync::LazyLock (edition 2024 → Rust 1.85+) src/ui/tui/progress.rs (3 regex)
once_cell::sync::Lazy / OnceCell std::sync::LazyLock / OnceLock executor/output_sync.rs, pty/terminal.rs, utils/logging.rs, ssh/ssh_config/env_cache/global.rs, ssh/config_cache/global.rs
fastrand::u64(range) rand::random_range(range) (rand 0.10 already direct dep) 3 forwarding reconnect-jitter sites
directories::ProjectDirs / BaseDirs dirs::config_dir / dirs::home_dir (unify on dirs, already used in 16 sites) config/loader.rs, ssh/known_hosts.rs
ctrlc::set_handler tokio::signal::ctrl_c in tokio::spawn, guarded by Handle::try_current commands/interactive_signal.rs
signal-hook = "0.4.4" signal-hook = "0.3" (shares the instance crossterm already pulls in via signal-hook-mio); identical signatures for Signals::new, forever, consts::SIGWINCH — no source change Cargo.toml only

arrayvec was declared but unused anywhere in the source tree, so it is simply dropped.

Test plan

  • cargo build --workspace
  • cargo test -p bssh — 1303 tests passing, 0 failures
  • cargo clippy -p bssh --all-targets --no-deps — no warnings
  • cargo fmt -p bssh --check — clean
  • Verified signal-hook dedupes to a single 0.3.18 instance shared with crossterm

Audit the full direct dependency set in `Cargo.toml`, then remove or replace crates that were dead, redundant with the standard library, or duplicated with an existing dependency. Five crates (`arrayvec`, `ctrlc`, `directories`, `signal-hook 0.4.4`, plus the macOS `objc2`/`block2`/`dispatch2` chain pulled in by `ctrlc`) are now completely gone from the build graph; three more (`lazy_static`, `once_cell`, `fastrand`) remain transitively but are no longer directly referenced by our code.

Replacements:

- `lazy_static!` → `std::sync::LazyLock` in `src/ui/tui/progress.rs` (edition 2024 already mandates Rust 1.85+).
- `once_cell::sync::Lazy` / `OnceCell` → `std::sync::LazyLock` / `OnceLock` across `executor/output_sync.rs`, `pty/terminal.rs`, `utils/logging.rs`, `ssh/ssh_config/env_cache/global.rs`, `ssh/config_cache/global.rs`.
- `fastrand::u64(range)` → `rand::random_range(range)` in the three forwarding reconnect-jitter sites; `rand` 0.10 was already a direct dependency.
- `directories::ProjectDirs` / `BaseDirs` → `dirs::config_dir` / `dirs::home_dir`, unifying on `dirs` which was already used in 16 other sites and produces equivalent platform paths.
- `ctrlc::set_handler` → `tokio::signal::ctrl_c` inside a `tokio::spawn`, guarded by `Handle::try_current` to preserve the previous best-effort semantics in non-runtime contexts. The only caller (`execute_traditional`) is already async, and the matching test runs under `#[tokio::test]`.
- `signal-hook = "0.4.4"` → `"0.3"` so we share the same instance `crossterm` already pulls in via `signal-hook-mio`. Our usage (`Signals::new`, `Signals::forever`, `consts::SIGWINCH`) has identical signatures across both major lines, so no source change was needed — only the `Cargo.toml` pin.

The `arrayvec` crate was declared but unused anywhere in the source tree, so it is simply dropped.

Build, full `cargo test -p bssh` (1303 tests), `cargo clippy --all-targets`, and `cargo fmt --check` all pass. `Cargo.lock` loses 76 lines including the entire `signal-hook 0.4.4` subtree.
@inureyes inureyes added type:refactor Code refactoring type:dependency Dependency updates status:review Under review priority:medium Medium priority issue and removed type:dependency Dependency updates labels May 11, 2026
@inureyes inureyes merged commit 72169fe into main May 11, 2026
2 checks passed
@inureyes inureyes deleted the refactor/drop-stale-deps branch May 11, 2026 12:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:review Under review type:refactor Code refactoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant