Skip to content

fix(cli): handle read-only files when overwriting .preview folder#11483

Merged
fern-support merged 2 commits intomainfrom
devin/1767984596-fix-preview-overwrite
Jan 9, 2026
Merged

fix(cli): handle read-only files when overwriting .preview folder#11483
fern-support merged 2 commits intomainfrom
devin/1767984596-fix-preview-overwrite

Conversation

@jsklan
Copy link
Copy Markdown
Contributor

@jsklan jsklan commented Jan 9, 2026

Description

Fixes fern generate --preview failing with EACCES: permission denied errors when the .preview folder already exists from a previous run.

Link to Devin run: https://app.devin.ai/sessions/0807c2beab2146e980ed354374695cb8
Requested by: @jsklan

Problem

When running fern generate --preview multiple times, the CLI would fail with:

EACCES: permission denied, open '.../.preview/fern-typescript-sdk/.git/objects/...'

This happens because:

  1. The generated SDK zip may include a .git directory
  2. Git creates .git/objects files with read-only permissions
  3. Node.js rm() fails to delete read-only files on some systems
  4. The subsequent decompress fails when trying to write to existing files

Changes Made

  • Added forceRemoveDirectory() helper that makes files writable before deletion
  • Added makeWritableRecursive() helper to recursively chmod files to 0o755
  • Updated downloadZipForTask() to use the new force removal
  • Updated downloadFilesWithFernIgnoreInTempRepo() for consistency
  • Added changelog entry for version 3.37.2

Testing

  • Manual testing: Verified lint checks pass (pnpm run check)
  • Unit tests added/updated (no new tests - the fix is in file system operations that are difficult to unit test without mocking)

Human Review Checklist

  • Verify the recursive chmod approach handles edge cases safely (symlinks, special files)
  • Confirm error suppression in makeWritableRecursive is appropriate (errors are ignored since files may be deleted/inaccessible mid-operation)
  • Check that chmod to 0o755 is the appropriate permission level for this use case
  • Note: This fix hasn't been tested on the actual failing scenario (macOS with .git/objects files) - only lint checks verified

Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Co-Authored-By: judah@buildwithfern.com <jsklan.development@gmail.com>
@fern-support fern-support merged commit 98a3b7a into main Jan 9, 2026
102 checks passed
@fern-support fern-support deleted the devin/1767984596-fix-preview-overwrite branch January 9, 2026 19:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants