Skip to content

Fix getPackageManager logic with workspaces#7253

Merged
gonzaloriestra merged 1 commit intomainfrom
fix-get-package-manager-workspaces
Apr 13, 2026
Merged

Fix getPackageManager logic with workspaces#7253
gonzaloriestra merged 1 commit intomainfrom
fix-get-package-manager-workspaces

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

@gonzaloriestra gonzaloriestra commented Apr 13, 2026

WHY are these changes introduced?

In #7228 we updated the logic to find out the current package manager to find the closest package.json instead of using npm prefix, but apparently it's not equivalent.

WHAT is this pull request doing?

Instead of looking for a package.json, look for the lock file.

How to test your changes?

Go to an extension folder with a package.json and run shopify version --verbose. The env_package_manager field in the analytics payload should be the one used in your app root folder.

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, so I've added a changelog entry with pnpm changeset add

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions
Copy link
Copy Markdown
Contributor

Differences in type declarations

We detected differences in the type declarations generated by Typescript for this branch compared to the baseline ('main' branch). Please, review them to ensure they are backward-compatible. Here are some important things to keep in mind:

  • Some seemingly private modules might be re-exported through public modules.
  • If the branch is behind main you might see odd diffs, rebase main into this branch.

New type declarations

We found no new type declarations in this PR

Existing type declarations

packages/cli-kit/dist/public/node/node-package-manager.d.ts
@@ -60,6 +60,10 @@ export declare class FindUpAndReadPackageJsonNotFoundError extends BugError {
 export declare function packageManagerFromUserAgent(env?: NodeJS.ProcessEnv): PackageManager;
 /**
  * Returns the dependency manager used in a directory.
+ * Walks upward from  so workspace packages (e.g. )
+ * still resolve to the repo root lockfile ().
+ * If no lockfile is found, it falls back to the package manager from the user agent.
+ * If the package manager from the user agent is unknown, it returns 'npm'.
  * @param fromDirectory - The starting directory
  * @returns The dependency manager
  */

@gonzaloriestra
Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

🫰✨ Thanks @gonzaloriestra! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

npm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260413112218

Caution

After installing, validate the version by running shopify version in your terminal.
If the versions don't match, you might have multiple global instances installed.
Use which shopify to find out which one you are running and uninstall it.

@gonzaloriestra gonzaloriestra marked this pull request as ready for review April 13, 2026 11:36
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner April 13, 2026 11:36
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 13, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 13, 2026
@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 13, 2026
Merged via the queue into main with commit a21a899 Apr 13, 2026
24 of 25 checks passed
@gonzaloriestra gonzaloriestra deleted the fix-get-package-manager-workspaces branch April 13, 2026 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants