[wp-trac] [WordPress Trac] #64874: `postinstall` scripts are failing in some environments
WordPress Trac
noreply at wordpress.org
Tue Mar 17 15:06:27 UTC 2026
#64874: `postinstall` scripts are failing in some environments
------------------------------+--------------------
Reporter: desrosj | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: 7.0
Component: Build/Test Tools | Version:
Severity: normal | Keywords:
Focuses: |
------------------------------+--------------------
A [https://wordpress.slack.com/archives/C3D6T7F8Q/p1773395499967809 Host
Test participant surfaced a bug] in the recent changes to the build
process, mainly [61458] and [61492] which added and modified `postinstall`
scripts.
Here's the relevant log output:
{{{
cd '/home/wptestrunners2q3/tmp' && source
/home/wptestrunners2q3/nodevenv/tmp/20/bin/activate && npm install && bash
/home/wptestrunners2q3/patch_gruntfile.sh
/home/wptestrunners2q3/tmp/Gruntfile.js && npm run build --force
> WordPress at 7.0.0 postinstall
> npm run gutenberg:verify
> WordPress at 7.0.0 gutenberg:verify
> node tools/gutenberg/utils.js
node:internal/modules/cjs/loader:1210
throw err;
^
Error: Cannot find module
'/home/wptestrunners2q3/nodevenv/tmp/20/lib/tools/gutenberg/utils.js'
at Module._resolveFilename (node:internal/modules/cjs/loader:1207:15)
at Module._load (node:internal/modules/cjs/loader:1038:27)
at Function.executeUserEntryPoint [as runMain]
(node:internal/modules/run_main:164:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.20.0
npm error code 1
npm error path /home/wptestrunners2q3/nodevenv/tmp/20/lib
npm error command failed
npm error command sh -c npm run gutenberg:verify
npm error A complete log of this run can be found in:
/home/wptestrunners2q3/.npm/_logs/2026-03-17T14_10_59_295Z-debug-0.log
Error: Failed to perform operation.
Environment variables pass checks.
cd '/home/wptestrunners2q3/tmp' && /usr/local/bin/php -q
./vendor/phpunit/phpunit/phpunit --dont-report-useless-tests
Could not open input file: ./vendor/phpunit/phpunit/phpunit
Error: Failed to perform operation.
Environment variables pass checks.
Getting SVN Revision
Getting SVN message
Copying junit.xml results
rsync -r '/home/wptestrunners2q3/tmp'/tests/phpunit/build/logs/*
'/home/wptestrunners2q3/tmp'
rsync: change_dir "/home/wptestrunners2q3/tmp/tests/phpunit/build/logs"
failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous errors)
(code 23) at main.c(1187) [sender=3.1.3]
Error: Failed to perform operation.
}}}
After debugging a bit with Claude, it seems that when `nodevenv` is used
as a wrapper for Node.js, it causes some issues with relative paths when
running `postinstall` scripts.
{{{
When nodevenv is active, it sets NPM_CONFIG_PREFIX to the virtual
environment directory (/home/wptestrunners2q3/nodevenv/tmp/20). This
causes npm to treat the WordPress package as if it were being installed to
$prefix/lib/, making npm run the postinstall lifecycle script with CWD set
to that prefix lib path — not the actual project source directory.
Chain of events:
npm install runs with nodevenv's prefix active
npm triggers postinstall → npm run gutenberg:verify → node
tools/gutenberg/utils.js
npm sets the script's CWD to what it considers the package root:
/home/wptestrunners2q3/nodevenv/tmp/20/lib
tools/gutenberg/utils.js doesn't exist there → error
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/64874>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list