Opened 8 weeks ago
Closed 3 days ago
#64874 closed defect (bug) (fixed)
`postinstall` scripts are failing in some environments
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Build/Test Tools | Keywords: | has-patch commit fixed-major dev-reviewed |
| Focuses: | Cc: |
Description
A 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@7.0.0 postinstall
> npm run gutenberg:verify
> WordPress@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
Change History (14)
This ticket was mentioned in PR #11275 on WordPress/wordpress-develop by @desrosj.
8 weeks ago
#1
- Keywords has-patch added
#2
@
8 weeks ago
One option to fix this is to remove the postinstall scripts entirely. gutenberg:verify is the first Grunt task when build is run, which ensures the gutenberg directory is present and contains the files for the commit SHA value pinned in the package.json file.
However, a potential downside of this approach is that the files will not be present locally unless someone runs a build command. In my opinion, this is reasonable because there are other files that must also be built for WP to be usable (this is documented in the README.md, though probably deserves it's own section.
Other solutions I have found so far do not seem to work across platforms.
@johnbillion commented on PR #11275:
8 weeks ago
#4
To answer the first question that popped into my head, what's the impact of this change?
Answer: The verifyGutenbergVersion() function no longer runs post install. This function verifies that the Gutenberg package was installed to its correct location with the correct SHA hash.
How necessary is that check? Can it be moved to the build script?
@desrosj commented on PR #11275:
8 weeks ago
#5
How necessary is that check? Can it be moved to the build script?
Essentially, that's what this PR does. Because gutenberg:verify is the first task listed in the `build` task, it just kicks the can down the road a bit.
This ticket was mentioned in Slack in #hosting by amykamala. View the logs.
8 weeks ago
This ticket was mentioned in Slack in #core by juanmaguitar. View the logs.
7 weeks ago
#9
@
7 weeks ago
Comment from @desrosj from today's Bug Scrub
This prevents some setups from running the unit test suite, so I'd like to resolve this during RC. It's a Build/Test tool change and the contents of all built files will be identical, so it's fine to commit after RC so long as there is double sign off.
https://wordpress.slack.com/archives/C02RQBWTW/p1774455948067049
This ticket was mentioned in Slack in #core by jorbin. View the logs.
5 days ago
#12
@
4 days ago
- Keywords dev-feedback commit fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening to consider for backporting.
It seems that
postinstallcan cause issues with certain setups, notablynodevenv.Trac ticket: Core-64874.
## Use of AI Tools