Build: Handle project paths containing spaces in dev script - #80519
Merged
manzoorwanijk merged 2 commits intoJul 21, 2026
Merged
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
manzoorwanijk
requested changes
Jul 21, 2026
manzoorwanijk
left a comment
Member
There was a problem hiding this comment.
I think a better solution here is to use cross-spawn which is already used by the build script
The changes needed (click to expand)
diff --git a/tools/build-scripts/dev.mjs b/tools/build-scripts/dev.mjs
index 2759f9ebb30..0685f22d6a4 100644
--- a/tools/build-scripts/dev.mjs
+++ b/tools/build-scripts/dev.mjs
@@ -3,7 +3,8 @@
/**
* External dependencies
*/
-import { execSync, spawn } from 'child_process';
+import { execSync } from 'child_process';
+import spawn from 'cross-spawn';
import { fileURLToPath } from 'url';
import { parseArgs } from 'util';
import path from 'path';
@@ -29,7 +30,6 @@ function exec( command, args = [], options = {} ) {
const childOptions = {
cwd: ROOT_DIR,
stdio: silent ? 'pipe' : 'inherit',
- shell: true,
...spawnOptions,
};
@@ -90,7 +90,6 @@ function execAsync( command, args = [], options = {} ) {
return spawn( command, args, {
cwd: ROOT_DIR,
stdio: 'inherit',
- shell: true,
...options,
} );
}
@@ -231,7 +230,6 @@ async function dev() {
const buildWatch = spawn( 'wp-build', [ '--watch' ], {
cwd: ROOT_DIR,
stdio: [ 'inherit', 'pipe', 'inherit' ],
- shell: true,
env: { ...process.env, NODE_ENV: 'development' },
} );
manzoorwanijk
enabled auto-merge (squash)
July 21, 2026 11:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #80516.
Fixes the build scripts so
npm run devworks correctly when the Gutenberg repository is located in a directory whose path contains spaces (for example, LocalWP's defaultLocal Sitesdirectory).Why?
The development build script was using
child_process.spawn()withshell: true. When script paths contained spaces, the shell split the path before execution, causing commands such asclean.mjsto fail with aMODULE_NOT_FOUNDerror.Instead of manually quoting script paths, this PR adopts the same approach already used by
build.mjsby switching tocross-spawn. This avoids shell parsing issues and provides a more robust, cross-platform solution.How?
Replace
child_process.spawnwithcross-spawnintools/build-scripts/dev.mjs.Remove
shell: truefrom:exec()execAsync()wp-build --watchprocessKeep script paths unchanged, allowing
cross-spawnto handle paths containing spaces correctly.Testing Instructions
MODULE_NOT_FOUNDerror.Screenshots or screencast
N/A