#64559 closed defect (bug) (fixed)
Build: copyBlockAssets fails when core block types directories contain subdirectories
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 7.0 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | General | Keywords: | has-patch |
| Focuses: | Cc: |
Description (last modified by )
Issue first described at https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544
Follow-up of #64393
Steps to reproduce:
- In
package.json, change.gutenberg.refto a recent Gutenberg hash (e.g.2654e7d13086e483855cedf089ba6f4e86c967d7) - Run
npm run build:dev - See the "Copying blocks..." step fail as it tries to copy a directory using
fs.copySync:
Unexpected error: Error: ENOTSUP: operation not supported on socket, copyfile 'wordpress-develop/gutenberg/build/scripts/block-library/navigation-link/shared' -> 'wordpress-develop/src/wp-includes/blocks/navigation-link/shared'
at Object.copyFileSync (node:fs:3085:11)
at copyBlockAssets (wordpress-develop/tools/gutenberg/copy-gutenberg-build.js:231:9)
Fix:
Let fs.cpSync handle the entire recursive copy.
Change History (6)
This ticket was mentioned in PR #10805 on WordPress/wordpress-develop by @mcsf.
2 months ago
#1
- Keywords has-patch added
@youknowriad commented on PR #10805:
2 months ago
#3
Replace manual file iteration via fs.cpSync — which didn't support unexpected nested directories in block types' source dirs — with fs.cpSync.
Do we want to support these random folders or only keep block types folders? AFAIK, this is the first time we do this right?
@mcsf commented on PR #10805:
2 months ago
#4
Do we want to support these random folders or only keep block types folders?
This is the choice I gave in https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544. My opinion is that it's not copyBlockAssets's job to have an opinion, and it certainly shouldn't fail. So:
copyBlockAssetsshould either copy or ignore (but not fail) folders- a discussion about conventions on dir structure, if desired, should happen in Gutenberg
AFAIK, this is the first time we do this right?
Yes and no. It's definitely not the first time we've added a directory under a block type:
$ find packages/block-library/src \ -mindepth 2 -maxdepth 2 \ -type d \ -not -path '*/test' \ -not -path '*/test/*' packages/block-library/src/comments/edit packages/block-library/src/navigation-link/link-ui packages/block-library/src/navigation-link/shared packages/block-library/src/file/utils packages/block-library/src/navigation/utils packages/block-library/src/navigation/edit packages/block-library/src/template-part/edit packages/block-library/src/social-link/icons packages/block-library/src/list-item/hooks packages/block-library/src/query/edit packages/block-library/src/terms-query/edit packages/block-library/src/cover/edit
But it is the only one ending up in the build artefacts:
$ find build/scripts/block-library \ -mindepth 2 -maxdepth 2 \ -type d build/scripts/block-library/navigation-link/shared
See https://core.trac.wordpress.org/ticket/64559
Issue first described in https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544
Replace manual file iteration via
fs.cpSync— which didn't support unexpected nested directories in block types' source dirs — withfs.cpSync.