Skip to content

Fix Windows auto-upgrade for local CLI installs#7555

Merged
alfonso-noriega merged 2 commits into
mainfrom
bun-executes-npm-to-autoupgrade
May 15, 2026
Merged

Fix Windows auto-upgrade for local CLI installs#7555
alfonso-noriega merged 2 commits into
mainfrom
bun-executes-npm-to-autoupgrade

Conversation

@alfonso-noriega
Copy link
Copy Markdown
Contributor

WHY are these changes introduced?

Fixes #0000

WHAT is this pull request doing?

How to test your changes?

Post-release steps

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes
  • I've considered analytics changes to measure impact
  • The change is user-facing — I've identified the correct bump type (patch for bug fixes · minor for new features · major for breaking changes) and added a changeset with pnpm changeset add

`currentProcessIsGlobal()` decides between global and local installs by
comparing the project root against `process.argv[1]`. The project root
flows through `getProjectDir` -> `findPathUpSync` -> `normalizePath` (pathe),
which always returns forward slashes on every platform. `process.argv[1]`
is OS-native, so on Windows it arrives backslash-separated and the raw
`startsWith` comparison ends up as:

  binDir:     C:\\Users\\me\\proj\\node_modules\\@Shopify\\cli\\bin\\run.js
  projectDir: C:/Users/me/proj
  binDir.startsWith(projectDir) => false

The local install was misclassified as global, so the postrun hook ran
`npm install -g @shopify/cli@latest` after every command on Windows even
when @shopify/cli was declared as a project dependency.

Switches the comparison to `isSubpath` (pathe.relative under the hood)
which tolerates either separator, and bails early if argv[1] is empty so
we don't accidentally classify it as 'in any directory'.

Adds a regression test that constructs the exact Windows shape (forward-
slash projectDir vs. backslash argv[1]) — the existing POSIX-shaped tests
happened to agree on slashes when CI runs on Linux, so they didn't catch
this.

Reported by Nick Wesselman; root cause analysis by River.
@alfonso-noriega alfonso-noriega requested a review from a team as a code owner May 15, 2026 09:36
Copy link
Copy Markdown
Contributor Author

alfonso-noriega commented May 15, 2026

@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label May 15, 2026
@alfonso-noriega alfonso-noriega added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit dd4e5c1 May 15, 2026
51 of 55 checks passed
@alfonso-noriega alfonso-noriega deleted the bun-executes-npm-to-autoupgrade branch May 15, 2026 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants