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

[ Error ] - NixOS - Corepack/Pnpm Version Mismatch/Internal Error #416

Open
byteshiva opened this issue Mar 3, 2024 · 2 comments
Open

Comments

@byteshiva
Copy link

Issue:
When attempting to use Corepack with pnpm@9.0.0-alpha.5 on NixOS, the installation process encounters an error due to a version mismatch. This issue also arises when enabling Corepack, leading to an internal error related to symlink creation in a read-only file system.

Error Messages:

  1. During pnpm installation:

    $ corepack use pnpm@*
    
    ERR_PNPM_BAD_PM_VERSION This project is configured to use v9.0.0-alpha.5+sha256.9b9b9a4f189d3837e7cfcabed63ab7b4afa6844ed98c6e1705bd70d0d9bef60b of pnpm. Your current pnpm is v9.0.0
    
  2. While enabling Corepack:

    $ corepack enable
    
    Internal Error: EROFS: read-only file system, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/nix/store/HIDDEN-HASH-CODE-nodejs-20.11.1/bin/pnpm'
    Error: EROFS: read-only file system, symlink '../lib/node_modules/corepack/dist/pnpm.js' -> '/nix/store/HIDDEN-HASH-CODE-nodejs-20.11.1/bin/pnpm'
    
    

Steps to Reproduce NodeJS Unstable Installation:

nix-shell -I nixpkgs=https://github.com/NixOS/nixpkgs/archive/nixos-unstable.tar.gz -p nodejs

Steps to Reproduce:

  1. Run the following commands to install pnpm:

    corepack use pnpm@*
    
  2. Attempt to enable Corepack:

    corepack enable
    

Environment Information:

  • Operating System: NixOS
  • Corepack Version: 0.23.0
  • pnpm Version: 9.0.0-alpha.5
  • NodeJS Version: v20.11.1
  • Nixpkgs Version: nixos-unstable

Expected Behavior:
The installation of pnpm and enabling Corepack should proceed without version mismatches or errors related to read-only file systems.

Actual Behavior:
Errors are encountered during the installation of pnpm, enabling Corepack

@aduh95
Copy link
Contributor

aduh95 commented Mar 3, 2024

The read-only issue was addressed by #244 specifically for the Nix-OS use case :) You could of course define your own nix expression to create a jumper script:

{ pkgs, nodejs }:

let
  pnpm-shim = pkgs.writeShellScriptBin "pnpm" "exec \"${pkgs.lib.getBin nodejs}/bin/node\" \"${pkgs.lib.getBin nodejs}/bin/corepack\" pnpm \"$@\"";

in pnpm-shim

The ERR_PNPM_BAD_PM_VERSION seems to be a PNPM bug, that error is not thrown by Corepack.

@byteshiva
Copy link
Author

byteshiva commented Mar 4, 2024

The read-only issue was addressed by #244 specifically for the Nix-OS use case :) You could of course define your own nix expression to create a jumper script:

Thanks,

I've written a blog on creating a custom pnpm script aka (jumper nix script) and integrating it with direnv.

blog -
https://byteshiva.medium.com/using-nix-to-create-a-custom-pnpm-script-and-integrate-with-direnv-a31017232e8d

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

2 participants