Skip to content

Fix project creation on read-only filesystems (NixOS)#854

Open
taciturnaxolotl wants to merge 1 commit intowpilibsuite:mainfrom
taciturnaxolotl:fix/nix-readonly-permissions
Open

Fix project creation on read-only filesystems (NixOS)#854
taciturnaxolotl wants to merge 1 commit intowpilibsuite:mainfrom
taciturnaxolotl:fix/nix-readonly-permissions

Conversation

@taciturnaxolotl
Copy link

@taciturnaxolotl taciturnaxolotl commented Mar 6, 2026

When the vscode-wpilib extension is installed via a read-only filesystem (e.g. the Nix store on NixOS), project creation fails with "Cannot create into non empty folder" because ncp preserves source file permissions when copying templates but files in the Nix store are read-only (0444). The copied project files inherit read-only permissions and then subsequent steps (e.g. replacing ###GRADLERIOREPLACE### in build.gradle) fail because fs.writeFile cannot write to read-only files.

Changes

  • permissions.ts: Add setWritableRecursive() helper that recursively ensures owner-write permission on all files/directories (no-op on Windows)
  • utilities.ts: Call setWritableRecursive(dest) after each ncp copy in ncpAsync to ensure copied files are always writable

This is a no-op on normal systems where files are already writable, and fixes project creation on NixOS and any other environment where the extension is installed on a read-only filesystem.

When the vscode-wpilib extension is installed on a read-only filesystem
(e.g. the Nix store on NixOS), ncp preserves the source's read-only
file permissions when copying template files to create a new project.
This causes project creation to fail because subsequent steps cannot
write to the copied files (e.g. replacing placeholders in build.gradle).

Add a setWritableRecursive helper that ensures all copied files have
the owner-write permission bit set, and call it after each ncp copy
in ncpAsync.

Fixes project creation on NixOS / systems using Nix package manager.
@taciturnaxolotl taciturnaxolotl force-pushed the fix/nix-readonly-permissions branch from 524ece9 to 085add5 Compare March 8, 2026 15:21
@taciturnaxolotl
Copy link
Author

fixed formatting

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.

1 participant