-
-
Notifications
You must be signed in to change notification settings - Fork 640
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
Use corepack to run package managers #21550
base: main
Are you sure you want to change the base?
Conversation
I would in general be wary of this because corepack is being removed from future versions of Node. I don't know offhand what the best solution might be, but I think it might be adding the actual underlying package manager binaries (pnpm, yarn, npm) inside the binaries directory instead of corepack. |
Sure. If that's the case I agree. But that feels like a separate task, no? Corepack usage is already there, moving to using the package managers themselves feels like a separate thing |
That's a fair counter; since we are using corepack today in many other places I think this is fair game too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution and thanks for waiting.
I'm unfamiliar with the details of corepack, the deprecation sounds unfortunate, but as observed, Pants already use it in places, so I'm going to get this in. We can revisit if @tobni or others (maybe @AlexTereshenkov?) have alternative ways to approach this.
Nodejs Corepack distribution being deprecated is something needs fixing, sure. Adding this feature doesn't really complicate that. To be clear, corepack isn't deprecated, just the node binaries distribution containing corepack. |
30c9ed4
to
de72643
Compare
pytest.param("npm", "10.8.2", id="npm"), | ||
pytest.param("pnpm", "9.5.0", id="pnpm"), | ||
pytest.param("npm", "10.9.0", id="npm"), | ||
pytest.param("pnpm", "9.12.3", id="pnpm"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking before merging: can you expand a bit on why these changed?
(No need to revert/change again, but I'd like to be sure that we don't have to update them again when new versions are released, so that these tests don't depend on external state.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, those are now picked up by the version installed via corepack. I'm not really sure on how we could lock them, when running the activate command for corepack perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, thanks.
It's definitely unexpected to me that setting --nodejs-package-managers={...}
with explicit versions doesn't end up using those exact versions, I think we may need to fix this.
@tobni, any opinions/advice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah, looking at https://github.com/nodejs/corepack?tab=readme-ov-file#utility-commands suggests that we could run like, for instance, args=("[email protected]", ...)
. So, maybe:
- add a method for getting the
...@...
installation specification toPackageManager
, e.g.:def spec(self) -> str: return f"{self.name}@{self.version}" if self.version is not None else self.name
- invoke the process with
args=(pkg_manager.spec(), ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, nice find. I'll try and see if I can get to it later this week
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just quickly tested this and it seems to work for all package managers except yarn that ends up with this error error Couldn't find a package.json file in "/private/tmp/pants-sandbox-pPJw4m"
Might be connected to nodejs/corepack#334
Hi folks, what's the status on this? @huonw , could this be merged as-is? |
I've gotten stuck on other work unfortunately and I didn't manage to get all package managers running with the version specified in the run args. yarn for example got caught on the error I wrote about earlier |
24d7301
to
f161f35
Compare
I made some changes so we're able to run package managers on a specific version. I was unable to get it running for yarn so therefor the somewhat ugly fix to disregard that specific package manager for now. Would love any help on getting it running with yarn as well but this will at least keep us from needing to update test versions as often :) |
This makes it possible to run NodeJSToolProcesses as interactive processes. Would be nice if we could setup aliases for each package manager instead perhaps as described here.
Do you have any pointers on how to solve it in another way than this?
Fixes #21205