Skip to content

feat(cli): friendly error when record/watch runs outside a Cargo project #70

Open

Description

@ymw0407

Running cargo-chronoscope record (or watch) in a directory without a Cargo.toml currently surfaces cargo's raw error through the supervisor pipeline, which is noisy. The user gets:

error: could not find `Cargo.toml` in `/some/path` or any parent directory

— wrapped in JSON event-stream warnings that are hard to parse for someone who just typo'd a cd.

Proposal

Detect the missing manifest before spawning cargo and exit with a clean error:

error: no Cargo.toml in /some/path or any parent directory.

cargo-chronoscope must be run from inside a Rust project (the same place `cargo build` would work). Try:
    cd /path/to/your/rust/project
    cargo-chronoscope record

Walk up from workspace_dir looking for Cargo.toml, identical to what cargo does. If none found, return a friendly anyhow! error from cmd_record / cmd_watch before reaching supervisor::spawn_build.

Acceptance

  • In a directory with no Cargo.toml (and no parent with one), cargo-chronoscope record exits non-zero with the friendly message above.
  • In a workspace root (Cargo.toml exists), behavior is unchanged.
  • In a workspace member (nested directory whose parent has Cargo.toml), behavior is unchanged.
  • Existing tests still pass; one new test covers the no-Cargo.toml case.

Files

  • src/main.rs — cmd_record, cmd_watch get a pre-flight check, or a small helper
  • tests/ — new integration test using tempfile::TempDir

Activity

  1. txhno commented on May 5, 2026

    @txhno
    Contributor

    ive fixed it here: #72

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions