-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Extension install fails in monorepo due to insufficient package manager detection #4028
Comments
Hey @echocrow, thanks for the bug report! I've merged a PR to update the package manager detection logic, which should cover your use case. I should note, however, that the CLI itself uses workspaces in a setup where the workspace root is the app project root, and each extension is a workspace. So if the apps themselves are workspaces, you are now creating nested workspaces. It's a bit difficult to find explicit documentation about this, but my understanding is that support for nested workspaces among package managers is still a bit iffy, and we can't guarantee that the CLI will work correctly in this setup. There may be a number of bugs we're unable to solve, and since this seems to be a rare setup among our users so far, it is also questionable whether we'll be able to dedicate time even if bugs are fundamentally solvable. If you're willing to take on those risks, then I earnestly wish you the best of luck pioneering the use of nested workspaces for Shopify apps. Let us know how it goes! |
@amcaplan Thanks for the update and fast PR! TIL, RE workspaces: Cheers for the precautionary note, and well understood! We've already been using this setup successfully for a few months now, including another non-Shopify app that also uses nested packages:
- 'apps/*'
- 'apps/another-app/extensions/*'
- 'apps/shopify/extensions/*'
- 'packages/*' Thanks to your PR, we won't have to work around the Shopify CLI anymore. (Previously we'd be passing |
Please confirm that you have:
In which of these areas are you experiencing a problem?
Extension
Expected behavior
Running
shopify generate extension
in an app folder inside a monorepo should work fine. It should scaffold the extension, and install new dependencies using the correct package manager.Actual behavior
When creating extensions, during "Installing dependencies ..." the CLI will error out with:
The CLI did not correct the right package manager (see "Reproduction steps" below). Expected
pnpm
, butnpm
was used as a fallback.Looks like the internal
getPackageManager(fromDirectory)
tries to check for local lockfiles, but in a monorepo, that would only be found at the root repo directory, but not in the nested app/package directory.Possible solutions(?):
app build
andapp dev
via--skip-dependencies-installation
app init
via--package-manager
Verbose output
... [DATETIME]: Reading the content of file at package.json... [DATETIME]: Obtaining the dependency manager in directory /path/to/repo/apps/my-shopify-app... [DATETIME]: Reading the content of file at package.json... ...
Reproduction steps
Sample monorepo project setup:
Sample step:
cd apps/my-shopify-app
shopify generate extension
Checkout UI
, and follow the remaining promptsOperating System
Multi platform
Shopify CLI version (check your project's
package.json
if you're not sure)v3.61.2
Shell
No response
Node version (run
node -v
if you're not sure)v20.11.1
What language and version are you using in your application?
No response
The text was updated successfully, but these errors were encountered: