-
Notifications
You must be signed in to change notification settings - Fork 173
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
corepack use
in monorepo targets root not project package.json
#607
Comments
We're missing a test on that, but if I remember correctly the intent is to update the closest package.json that contains a |
This comment has been minimized.
This comment has been minimized.
I went back and looked at the different cases. I think if
|
I'm not sure I follow - the test case below seems to return the expected results (it updates the monorepo root, not the workspace directory). Do you get something else?
|
I ran your example and the result is that it updates the monorepo root as you say. Your example is however a pure Yarn repo with workspaces where that behavior is probably desirable. The repo I am dealing with is https://github.com/cypress-io/github-action and that is a mixed npm, Yarn Classic, Yarn Modern, pnpm repo which demonstrates how to use Cypress in GitHub Actions with these different types of mainstream package managers and some different application frameworks. It also includes workspaces for both Yarn Classic and pnpm in projects in the hierarchy. I expect it will be one of the most complex setups in this regard. In this repo, if I execute I can probably work around this by creating an initial |
I see - yes, adding an explicit |
I will take a look at writing and submitting a separate user story for the special case as this would be a feature request. Having an option to determine the target location for I have split out the documentation issue and put it in #610. |
Current behavior
In a monorepo if
corepack use
is executed in a project directory, which is a sub-directory of a monorepo root directory containing an existingpackage.json
, it does not create or update thepackage.json
in the project directory. Instead it makes changes to thepackage.json
in the root of the monorepo.The monorepo is not a workspace. Each project is separate.
Expected behavior
If
corepack use
is executed in a monorepo project directory, it should operate on or create apackage.json
in that directory not in the root directory of the monorepo.The corepack README does not discuss how
corepack use
is supposed to behave in a hierarchy of directories containing their ownpackage.json
files. It says simply:The Node.js documentation for corepack Configuring a package says:
I would understand this to mean that if there is a
package.json
in the current working directory, thencorepack use
should act on thispackage.json
, and not search up the hierarchy to change a higher levelpackage.json
Step to reproduce
Ubuntu
24.04.1
LTS, Node.js22.13.0
LTS, Corepack0.30.0
package.json
in the root of the repo has been modified (notexamples/yarn-classic/package.json
) with the addition ofyarn install
has been run inexamples/yarn-classic
, creating a newexamples/yarn-classic/node_modules
directory there.Logs
The debug logs do not show which directory is being used to write a
package.json
file, nor which directoryyarn install
is being run in:The text was updated successfully, but these errors were encountered: