fix(cli): Use correct directory for upgrade-interactive #5272
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
upgrade-interactive
was updating thepackage.json
in the current directory (where Yarn was run) instead of where the upgrades were made. The most notable occurrence of this wasglobal upgrade-interactive
, but it also happened by using the--cwd
option.When the location was not a workspace, it resolved to the current directory instead of using the previously configured one. Additionally,
config.cwd
was changed without being cleaned up, so it contained the last processed workspace, which affected anything that used it afterwards (e.g. symlinking binaries).Fixes #4728
Fixes #4952
Fixes #4922
Test plan
Install any package globally, then upgrade it interactively without being in the global directory. (or with
--cwd
). The binary of the package that is being upgraded was symlinked again, but all other symlinks were removed.Before
After