[rush-lib] Add ensureFolderExists to plugin autoinstaller file writes#5697
Merged
octogonz merged 4 commits intomicrosoft:mainfrom Mar 12, 2026
Merged
Conversation
The read+write pattern introduced in PR microsoft#5678 replaced FileSystem.copyFile() which implicitly created destination folders. The writeFile() calls need ensureFolderExists: true to maintain the same behavior.
Collaborator
|
@copilot Add a "Fix a recent regression that sometimes produced ENOENT errors when installing autoinstallers" Also modify version-policies.json to make the next Rush publish a "patch" bump |
Copilot AI
added a commit
that referenced
this pull request
Mar 12, 2026
…sion bump Co-authored-by: octogonz <4673363+octogonz@users.noreply.github.com>
octogonz
approved these changes
Mar 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a bug introduced in #5678 where FileSystem.writeFile() fails if the destination folder does not yet exist. The previous FileSystem.copyFile() implementation implicitly created parent directories, but writeFile() does not.
Details
PR #5678 replaced FileSystem.copyFile() with readFile() + writeFile() to normalize line endings. However, copyFile() (backed by fs-extra.copySync) implicitly created destination directories, while writeFile() does not. This causes an ENOENT failure when the per-package subdirectory under rush-plugins/ hasn't been created yet.
PluginManager.updateAsync() calls ensureEmptyFolder(storePath) which creates the rush-plugins/ root, but the per-package subfolder (e.g. rush-plugins/@scope/package-name/) is not created before update() runs. The fix adds ensureFolderExists: true to both writeFile() calls, restoring the implicit directory creation behavior that copyFile() provided.
How it was tested
TODO: I'm currently in the process of adding a regression test for this. But since it's a hotfix for a bug, I figured I'd get the PR out first to let people know the issue exists.