Skip to content

fix(windows): avoid EPERM rename error during platform project creation#6066

Open
dyazincahya wants to merge 1 commit into
NativeScript:feat/windowsfrom
dyazincahya:feat/windows
Open

fix(windows): avoid EPERM rename error during platform project creation#6066
dyazincahya wants to merge 1 commit into
NativeScript:feat/windowsfrom
dyazincahya:feat/windows

Conversation

@dyazincahya

Copy link
Copy Markdown

PR Checklist

What is the current behavior?

When adding the windows platform to a project on Windows OS, the NativeScript CLI copies the platform template into a directory named __PROJECT_NAME__ under platforms/windows/, and subsequently attempts to rename it to the actual project name using Node's fs.rename function.

However, because background OS processes (such as Windows Defender real-time protection, search indexers, or antivirus scanners) instantly inspect/lock newly created folders, this immediate directory rename fails with a persistent EPERM: operation not permitted error, causing the platform setup command to crash.

What is the new behavior?

  1. Direct Copy Bypass: Modified the createProject function in windows-project-service.ts to copy the template directory directly using the target project name from the start. This completely eliminates the directory rename step (__PROJECT_NAME__ -> projectDir), bypassing the EPERM lock on the folder.
  2. Permissions Cleanup: Added a recursive clearReadOnlyRecursive helper using fs.chmodSync to strip any read-only properties from the platform project files on Windows before editing.
  3. Retry rename utility: Added a renameWithRetry utility featuring a 30-retry loop (with 300ms delays) to gracefully handle transient locks when renaming internal project files, such as the .csproj file.

EPERM: operation not permitted, rename 'C:\Users\....\DataDisk\projects\kang-cahya\nativescript\windows\nativescript-windows-pokedex\platforms\windows\__PROJECT_NAME__' -> 'C:\Users\....\DataDisk\projects\kang-cahya\nativescript\windows\nativescript-windows-pokedex\platforms\windows\nativescriptwindowspokedex'
@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 82241bef-48da-471b-8f23-b6f0f20a15bf

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants