Skip to content

Windows: migrate-directory fails with EPERM due to VS Code file watchers #135

Closed

Description

@spboyer

Description

squad upgrade --migrate-directory fails on Windows with:

EPERM: operation not permitted, rename

The migration uses fs.renameSync() to move .ai-team/ to .squad/. On Windows, this fails when VS Code (or any other file watcher) has handles open on files inside the directory.

Steps to reproduce

  1. Open a repo with .ai-team/ in VS Code
  2. Run npx github:bradygaster/squad upgrade --migrate-directory
  3. Migration fails with EPERM

Expected behavior

Migration completes successfully regardless of open file handles.

Suggested fix

Fall back to copy+delete when fs.renameSync fails with EPERM:

try {
  fs.renameSync(aiTeamDir, squadDir);
} catch (err) {
  if (err.code === 'EPERM' || err.code === 'EACCES') {
    // Copy + delete fallback for Windows file watcher locks
    copyRecursive(aiTeamDir, squadDir);
    fs.rmSync(aiTeamDir, { recursive: true, force: true });
  } else {
    throw err;
  }
}

The same pattern should apply to the .ai-team-templates/ → .squad-templates/ rename later in the migration.

Environment

  • OS: Windows 11
  • Squad version: v0.5.2
  • Editor: VS Code (file watcher active on repo)

Related

Activity

  1. added 2 commits that reference this issue on Feb 27, 2026
  2. bradygaster commented on Feb 27, 2026

    @bradygaster
    Collaborator

    Fixed in PR #149 (merged to dev). Added safeRename() helper that catches EPERM/EACCES on Windows and falls back to fs.cpSync + fs.rmSync. Both .ai-team/ -> .squad/ and .ai-team-templates/ -> .squad-templates/ renames now use the safe pattern.

  3. bradygaster commented on Feb 27, 2026

    @bradygaster
    Collaborator

    Fixed in PR #149 (merged to dev). Added safeRename() helper that catches EPERM/EACCES on Windows and falls back to fs.cpSync + fs.rmSync. Applied to both the .ai-team/ → .squad/ and .ai-team-templates/ → .squad-templates/ renames. Will ship in the next release.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions