Skip to content

bug: rr sync does not acquire lock, can overwrite files during active execution #181

@rileyhilliard

Description

@rileyhilliard

Summary

The standalone rr sync command does not acquire a lock before syncing files to the remote host. This means a rr sync from one terminal can overwrite source files on the remote while another terminal's rr run or rr <task> is actively executing against those files.

Expected behavior

rr sync should respect the lock system, same as rr run / rr exec / rr <task>. If a lock is held, rr sync should wait for it to release before syncing.

Current behavior

rr sync connects and syncs directly without checking or acquiring a lock. The SetupWorkflow path (used by rr run, rr exec, task execution) correctly acquires the lock before syncing:

Connect -> Lock -> Sync -> Execute -> Release

But rr sync (in internal/cli/sync.go) skips locking entirely:

Connect -> Sync

Reproduction

  1. Terminal 1: rr run "sleep 30" (acquires lock, syncs, runs)
  2. Terminal 2 (different worktree or after modifying files): rr sync
  3. Terminal 2's sync overwrites source files on remote while Terminal 1's command is still running

Suggested fix

Add lock acquisition to the Sync() function in internal/cli/sync.go, matching the pattern used by SetupWorkflow. The lock should be acquired before syncing and released after sync completes.

Found while reviewing #176.

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