Skip to content
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

How does this compare to run: corepack enable? #105

Open
mmkal opened this issue Nov 9, 2023 · 11 comments
Open

How does this compare to run: corepack enable? #105

mmkal opened this issue Nov 9, 2023 · 11 comments

Comments

@mmkal
Copy link

mmkal commented Nov 9, 2023

Similar to #30 - I am wondering if there's an advantage to using this vs just running corepack enable, which as far as I understand, will instruct node itself to download and install pnpm, and will respect the packageManager field in package.json.

I'm doing this in my expect-type repo (permalink) and it seems to be working - is there a downside that you know of?

@zkochan
Copy link
Member

zkochan commented Nov 10, 2023

The advantage is that this installs the "executable" version of pnpm, which is bundled with node.js using vercel/pkg. The "executable" version of pnpm is a bit faster and can run on any version of node.js.

@segevfiner
Copy link

Is this really true? Isn't this a flag https://github.com/pnpm/action-setup/tree/v2#standalone ?

@paescuj
Copy link

paescuj commented Dec 11, 2023

Surely, an advantage over corepack is that the action already takes care of store prune, see https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time.

@jrr
Copy link

jrr commented Feb 1, 2024

One downside is that corepack is still marked as experimental: https://nodejs.org/docs/latest-v20.x/api/corepack.html

@zkochan
Copy link
Member

zkochan commented Feb 2, 2024

@segevfiner yes, it is turned off by default at the moment.

There is nothing wrong with corepack. In our docs we actually recommend corepack for all CIs except Github actions: https://pnpm.io/continuous-integration. But there is nothing wrong with using corepack instead of this action.

@karlhorky
Copy link
Contributor

karlhorky commented Apr 19, 2024

Edit: as of pnpm/action-setup@v4, the error described below is surfaced proactively to users with suggestions how to fix the configuration.

One downside of pnpm/action-setup vs corepack enable is that it can lead to ERR_PNPM_BAD_PM_VERSION failures on pnpm install when using the packageManager field in package.json:

  1. Configure a pnpm/action-setup step with version: 'latest'
  2. Configure packageManager in package.json with an old version eg. "packageManager": "pnpm@9.0.3"
  3. Observe the ERR_PNPM_BAD_PM_VERSION error below on pnpm install on CI 💥
$ pnpm install
 ERR_PNPM_BAD_PM_VERSION  This project is configured to use v9.0.3 of pnpm. Your current pnpm is v9.0.4

If you want to bypass this version check, you can set the "package-manager-strict" configuration to "false" or set the "COREPACK_ENABLE_STRICT" environment variable to "0"

Workaround 1

Remove the version: 'latest' config to enable packageManager support:

       - uses: pnpm/action-setup@v3
         with:
-          version: 'latest'

Workaround 2

Switch pnpm/action-setup to corepack enable to resolve this error:

-      - uses: pnpm/action-setup@v3
-        with:
-          version: 'latest'
+      - run: corepack enable

Workaround 3

Always keep packageManager in package.json immediately up to date, eg. using a bot like Renovate bot

@karlhorky
Copy link
Contributor

karlhorky commented Apr 19, 2024

@zkochan because of the ERR_PNPM_BAD_PM_VERSION error above, maybe pnpm/action-setup should be removed as the recommendation for GitHub Actions?

(to avoid users running into this footgun, especially since packageManager is the recommended way of setting a pnpm version on some platforms like Netlify)

Or, alternatively, if pnpm/action-setup would automatically respect the version in packageManager in package.json, that would be another option (as a feature request to pnpm/action-setup).

@segevfiner
Copy link

Doesn't it already have a feature to look at packageManager if you don't specify version? Check the README, I remember I configured it like this.

@karlhorky
Copy link
Contributor

karlhorky commented Apr 19, 2024

Indeed, I somehow missed this!

As per the pnpm/action-setup docs about the version option, to use the packageManager version, you can just omit the version config:

version

Version of pnpm to install.

Optional when there is a packageManager field in the package.json.

However, this should probably error in the action when packageManager is set and version is specified.

I'll create an issue

@karlhorky
Copy link
Contributor

Ok I ended up creating a PR for this instead - to throw an error if multiple versions of pnpm are specified:

@jasonkuhrt
Copy link

It seems that using core pack does not enable global installs?

Run pnpm install -g tsx
 ERR_PNPM_NO_GLOBAL_BIN_DIR  Unable to find the global bin directory

Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.

https://github.com/graffle-js/graffle/actions/runs/11783197937/job/32819852527?pr=1259

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

No branches or pull requests

7 participants