Skip to content

Use findUp instead of npm prefix to find the project folder#7228

Open
gonzaloriestra wants to merge 1 commit intomainfrom
replace-npm-prefix
Open

Use findUp instead of npm prefix to find the project folder#7228
gonzaloriestra wants to merge 1 commit intomainfrom
replace-npm-prefix

Conversation

@gonzaloriestra
Copy link
Copy Markdown
Contributor

@gonzaloriestra gonzaloriestra commented Apr 9, 2026

WHY are these changes introduced?

Related to: https://shopify.slack.com/archives/C07UJ7UNMTK/p1775663292357249

getPackageManager() spawns npm prefix as a subprocess to locate the project root. If npm is unavailable, the subprocess fails and the function falls back to the user agent string. When the CLI is invoked directly (not via pnpm shopify), the user agent is unset, so the package manager resolves to "unknown" — causing commands like shopify app generate extension to fail with spawn unknown ENOENT.

WHAT is this pull request doing?

Replaces the npm prefix subprocess call with findPathUp('package.json'), a pure-filesystem walk that's already available in cli-kit. This eliminates the dependency on npm, making package manager detection reliable regardless of how the CLI is invoked.

How to test your changes?

  • pnpm i -g --@shopify:registry=https://registry.npmjs.org @shopify/cli@0.0.0-snapshot-20260409112001
  • shopify app init
  • shopify app generate extension --template checkout_ui --name test-ext

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

@gonzaloriestra
Copy link
Copy Markdown
Contributor Author

/snapit

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🫰✨ 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-20260409112001

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 9, 2026 11:48
@gonzaloriestra gonzaloriestra requested a review from a team as a code owner April 9, 2026 11:48
Copy link
Copy Markdown
Contributor Author

gonzaloriestra commented Apr 9, 2026

Merge activity

  • Apr 9, 1:41 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Apr 9, 1:41 PM UTC: @gonzaloriestra added this pull request to the GitHub merge queue with Graphite.

@gonzaloriestra gonzaloriestra added this pull request to the merge queue Apr 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 9, 2026
@dmerand
Copy link
Copy Markdown
Contributor

dmerand commented Apr 10, 2026

I can see this is merging, and it may be the right fix for the immediate problem. I just want to make sure we’re explicitly aligned on the architectural direction here.

As I understand it, this changes getPackageManager(...) from:

  • npm prefix → project/workspace root

to:

  • findPathUp('package.json') → nearest package root

I’ve been working on a follow-up stack under a different assumption: keep the root/workspace-oriented behavior for the broad helper, then add narrower helper boundaries for cases that need different intent:

So this PR seems like more than an implementation detail — it changes the default resolution model. If that shift is intentional, I should probably rework parts of my stack accordingly, especially #7241. I mostly want to confirm we’re aligned that the architectural direction is changing here, rather than just fixing the npm prefix subprocess dependency.

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.

4 participants