Skip to content

Fix: npm run build:apps path resolution for paths with spaces - #740

Merged
AllTerrainDeveloper merged 3 commits into
WordPress:trunkfrom
CookieDarb:fix/apps-build-path-resolution
Sep 3, 2026
Merged

Fix: npm run build:apps path resolution for paths with spaces#740
AllTerrainDeveloper merged 3 commits into
WordPress:trunkfrom
CookieDarb:fix/apps-build-path-resolution

Conversation

@CookieDarb

@CookieDarb CookieDarb commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

What?

Closes #738

Fixes the bug where npm run build:apps (and npm run build) fails with ENOENT when the repository is located in a directory path containing spaces.

Why?

bin/build-apps.mjs previously resolved the project root directory using new URL( '..', import.meta.url ).pathname, which resolved spaces to %20, causing readdirSync to receive an invalid filesystem path and build failed with ENOENT: no such file or directory.

How?

  • bin/build-apps.mjs:
    • Used fileURLToPath from node:url to correctly resolve and decode the native filesystem path for the project root.
    • Added an existsSync( appsDir ) guard matching vite.config.js to safely exit with code 0 if no apps directory exists.

Testing Instructions

  1. Place or clone the plugin in a directory path with spaces (e.g. Local Sites/ or /tmp/test space/desktop-mode).
  2. Run npm run build:apps or npm run build.
  3. Verify that all apps (code-blue, my-wordpress, os-settings, trash) compile successfully into assets/js/apps/ with exit code 0.

Use of AI Tools

AI assistance: Yes
Tool(s): Antigravity
Model(s): Gemini
Used for: Investigating the build error and suggesting changes. Final decisions and edits were made by me.

Open WordPress Playground Preview

@AllTerrainDeveloper AllTerrainDeveloper left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! LGTM!

@AllTerrainDeveloper
AllTerrainDeveloper enabled auto-merge (squash) September 3, 2026 10:05
@AllTerrainDeveloper
AllTerrainDeveloper merged commit 3635a03 into WordPress:trunk Sep 3, 2026
8 of 9 checks passed
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.

npm run build:apps fails with ENOENT when directory path contains spaces

2 participants