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

feat: store packageManager property also inside the lock file #465

Open
ruscon opened this issue Apr 22, 2024 · 5 comments
Open

feat: store packageManager property also inside the lock file #465

ruscon opened this issue Apr 22, 2024 · 5 comments

Comments

@ruscon
Copy link

ruscon commented Apr 22, 2024

Our current flow:
We use docker + pnpm fetch

COPY --chown=node:node pnpm-*.yaml .npmrc ./
RUN npm install -g pnpm@^8 # curernt usage without corepack
# RUN corepack enable #  <= but we want this one
RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm fetch --loglevel=warn --ignore-scripts

This means we don't cache the package.json file before the pnpm fetch execution.
This allows us to worry about package.json changes.
But corepack will always install the latest version of pnpm instead of a specific one.

If store the packageManager property in a lock file, this will solve the problem.

@ruscon ruscon changed the title feat: store packageManager property also inside lock file feat: store packageManager property also inside the lock file Apr 22, 2024
@styfle
Copy link
Member

styfle commented Apr 23, 2024

This sounds like it should be implemented in pnpm and not corepack

@ruscon
Copy link
Author

ruscon commented Apr 23, 2024

@styfle Perhaps, but I don’t know how corepack works under the hood.
Most likely some kind of layer is needed for interaction between corepack and a package manager, so that the package manager itself updates its lock file?

@aduh95
Copy link
Contributor

aduh95 commented Apr 24, 2024

Have you considered setting a packageManager in your package.json? That way, Corepack would pick up the correct version when run inside the container. I'm not sure I understand why package.json couldn't be the "lock file" in this case.

@ruscon
Copy link
Author

ruscon commented Apr 24, 2024

@aduh95 The question is related to how the docker cache and pnpm fetch work.
pnpm fetch and npm ci can be run without a package.json file, which helps cache the installation of npm packages inside the docker image even if you make changes to the package.json file.

@aduh95
Copy link
Contributor

aduh95 commented Apr 24, 2024

I see, pardon my ignorance, I should have read the docs. From what I can see, pnpm docs recommend downloading a specific version of pnpm with cURL globally. The equivalent with corepack would be to run corepack install -g [email protected]. So IIUC, what you're requesting would be to have a way to skip the command and have pnpm fetch select the correct version. I don't know enough pnpm internals to tell how easy/hard that would be to implement, but I agree that would require changes on pnpm side – so that package.json it generates contains the correct "packageManager" field.

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

3 participants