From d836342a2a618a8bc0e9bafbe32d6fedd4de1d7a Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Wed, 18 Feb 2026 20:13:12 +0100 Subject: [PATCH 1/3] Build: Invoke Gutenberg build script directly to fix base-url argument passing. When building Gutenberg via `npm run build -- --base-url=...`, npm forwards arguments through a shell layer, which can mangle the `--base-url` value (containing spaces, parentheses, and single quotes) on some platforms. This caused the generated `constants.php` to be missing the trailing slash in the `build_url`. Invoke `node bin/build.mjs` directly instead, bypassing npm's shell forwarding entirely. The argument is passed as a single array element via `spawn` with `shell: false`, so it arrives intact regardless of platform. Props youknowriad. Fixes #64656. Co-Authored-By: Claude Opus 4.6 --- tools/gutenberg/build-gutenberg.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tools/gutenberg/build-gutenberg.js b/tools/gutenberg/build-gutenberg.js index 1dc1f73a4ec69..40efdcb471484 100644 --- a/tools/gutenberg/build-gutenberg.js +++ b/tools/gutenberg/build-gutenberg.js @@ -141,14 +141,11 @@ async function main() { const startTime = Date.now(); try { - // On Windows, shell mode is used and needs the argument wrapped in quotes - // On Unix, arguments are passed directly without shell parsing - const baseUrlArg = - process.platform === 'win32' - ? '--base-url="includes_url( \'build/\' )"' - : "--base-url=includes_url( 'build/' )"; - - await exec( 'npm', [ 'run', 'build', '--', '--skip-types', baseUrlArg ], { + await exec( 'node', [ + 'bin/build.mjs', + '--skip-types', + "--base-url=includes_url( 'build/' )", + ], { cwd: gutenbergDir, } ); From cbb9ee24503fe8669153a80b53dd9d754adc32aa Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Wed, 18 Feb 2026 20:20:23 +0100 Subject: [PATCH 2/3] Build: Add node_modules/.bin to PATH when invoking Gutenberg build directly. When bypassing `npm run build` to call `node bin/build.mjs` directly, the `node_modules/.bin` directory is not on the PATH. This caused `wp-build` (used internally by the build script) to fail with ENOENT on CI. Follow-up to [60573]. Props youknowriad. Fixes #64656. Co-Authored-By: Claude Opus 4.6 --- tools/gutenberg/build-gutenberg.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/gutenberg/build-gutenberg.js b/tools/gutenberg/build-gutenberg.js index 40efdcb471484..01cf4489de1fa 100644 --- a/tools/gutenberg/build-gutenberg.js +++ b/tools/gutenberg/build-gutenberg.js @@ -141,12 +141,22 @@ async function main() { const startTime = Date.now(); try { + // Invoke the build script directly with node instead of going through + // `npm run build --` to avoid shell argument mangling of the base-url + // value (which contains spaces, parentheses, and single quotes). + // The PATH is extended with node_modules/.bin so that bin commands + // like `wp-build` are found, matching what npm would normally provide. + const binPath = path.join( gutenbergDir, 'node_modules', '.bin' ); await exec( 'node', [ 'bin/build.mjs', '--skip-types', "--base-url=includes_url( 'build/' )", ], { cwd: gutenbergDir, + env: { + ...process.env, + PATH: binPath + path.delimiter + process.env.PATH, + }, } ); const duration = Math.round( ( Date.now() - startTime ) / 1000 ); From b717746ad6601d646b399237ed65994d40784790 Mon Sep 17 00:00:00 2001 From: Riad Benguella Date: Thu, 19 Feb 2026 04:29:58 +0100 Subject: [PATCH 3/3] Build: Add debug output for Gutenberg constants.php in CI. Temporarily dumps the contents of constants.php from both the Gutenberg build output and the final WordPress build directory to help diagnose the missing trailing slash issue. Props youknowriad. See #64656. Co-Authored-By: Claude Opus 4.6 --- .github/workflows/reusable-test-core-build-process.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/reusable-test-core-build-process.yml b/.github/workflows/reusable-test-core-build-process.yml index 4bec59e285c57..d71f79415865a 100644 --- a/.github/workflows/reusable-test-core-build-process.yml +++ b/.github/workflows/reusable-test-core-build-process.yml @@ -122,6 +122,15 @@ jobs: - name: Ensure version-controlled files are not modified or deleted during building run: git diff --exit-code + - name: Verify Gutenberg constants.php + if: ${{ inputs.directory == 'build' }} + run: | + echo "--- Gutenberg build output ---" + cat gutenberg/build/constants.php 2>/dev/null || echo "File not found in gutenberg/build/" + echo "" + echo "--- WordPress wp-includes/build/constants.php ---" + cat ${{ inputs.directory }}/wp-includes/build/constants.php 2>/dev/null || echo "File not found in ${{ inputs.directory }}/wp-includes/build/" + - name: Create ZIP of built files if: ${{ inputs.directory == 'build' && contains( inputs.os, 'ubuntu-' ) }} run: zip -r wordpress.zip build/.