Skip to content

Auto-discover project root by walking up to find .rr.yaml #154

@rileyhilliard

Description

@rileyhilliard

Problem

When running rr from a subdirectory of the project (e.g., opendata/opendata/ instead of opendata/), commands fail or sync incorrectly because rr uses the current working directory as the project root.

This is a common footgun when navigating around a project.

Proposed Solution

Walk up the directory tree to find .rr.yaml, similar to how other tools work:

  • git finds .git directory
  • npm/bun find package.json
  • cargo finds Cargo.toml
  • make with -C or --directory flag

Implementation

1. Check if .rr.yaml exists in cwd
2. If not, check parent directory
3. Repeat until .rr.yaml found or filesystem root reached
4. Use found directory as project root for all operations

Behavior

# From project root - works as today
cd ~/projects/myapp
rr test

# From subdirectory - should also work
cd ~/projects/myapp/src/components
rr test  # Walks up, finds .rr.yaml in ~/projects/myapp, uses that as root

Edge Cases

  • Multiple .rr.yaml files in parent chain: use the nearest one (most nested)
  • No .rr.yaml found: error with helpful message
  • Optional --root flag to override auto-discovery

Alternatives

  1. Always require running from project root - Current behavior, error-prone
  2. Explicit --root flag - Verbose, easy to forget
  3. Environment variable - Could complement auto-discovery

Prior Art

Tool Config file Auto-discovery
git .git/ Yes, walks up
npm package.json Yes, walks up
cargo Cargo.toml Yes, walks up
rr .rr.yaml No (proposed)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions