Skip to content

Fix clean task Error: ENOTEMPTY: directory not empty, rmdir#1911

Merged
colinrotherham merged 2 commits into
support/10.xfrom
enotempty
Apr 30, 2026
Merged

Fix clean task Error: ENOTEMPTY: directory not empty, rmdir#1911
colinrotherham merged 2 commits into
support/10.xfrom
enotempty

Conversation

@colinrotherham
Copy link
Copy Markdown
Contributor

@colinrotherham colinrotherham commented Apr 29, 2026

Description

This PR is a workaround to an issue with Node.js fsPromises.rm() where deleting large directories such as packages/nhsuk-frontend/dist throws ENOTEMPTY or other errors when the file system is busy

[Error: ENOTEMPTY: directory not empty, rmdir '/path/to/nhsuk-frontend/packages/nhsuk-frontend/dist'] {
  errno: -66,
  code: 'ENOTEMPTY',
  syscall: 'rmdir',
  path: '/path/to/nhsuk-frontend/packages/nhsuk-frontend/dist'
}

Checklist

@colinrotherham colinrotherham added the 🐛 bug Something isn't working the way it should (including incorrect wording in documentation) label Apr 29, 2026
@colinrotherham colinrotherham temporarily deployed to nhsuk-frontend-pr-1911 April 29, 2026 11:07 Inactive
@sonarqubecloud
Copy link
Copy Markdown

],
"scripts": {
"clean": "del-cli dist",
"clean": "del-cli dist/nhsuk/*",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The del package doesn't set maxRetries when removing files or directories

But updating the glob distdist/nhsuk/* splits out multiple paths to delete which appears to solve the problem (i.e. smaller batched deletes rather than one large delete)

Comment thread shared/lib/components.mjs
*/
export function getNames() {
const listing = files.getDirectories('nhsuk/components', {
const listing = files.getListing('nhsuk/components/*/template.njk', {
Copy link
Copy Markdown
Contributor Author

@colinrotherham colinrotherham Apr 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change fixes an issue where switching branches would leave empty directories behind, which then causes errors when trying to run file operations or build tasks on them

E.g. packages/nhsuk-frontend/src/nhsuk/components/search-input

@colinrotherham colinrotherham merged commit 68c54eb into support/10.x Apr 30, 2026
24 checks passed
@colinrotherham colinrotherham deleted the enotempty branch April 30, 2026 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working the way it should (including incorrect wording in documentation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants