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

pnpm link, unlink is corrupting /pnpm-global/ #4638

Open
JasonKleban opened this issue Apr 28, 2022 · 3 comments
Open

pnpm link, unlink is corrupting /pnpm-global/ #4638

JasonKleban opened this issue Apr 28, 2022 · 3 comments

Comments

@JasonKleban
Copy link

pnpm version: 6.32.9 (but not limited to this version)

Code to reproduce the issue:

basically this:

> rm -r -Force $($([Environment]::GetFolderPath([Environment+SpecialFolder]::ApplicationData)) + "\npm\pnpm-global")
c:\repos\a> pnpm link --global
c:\repos\b> pnpm link --global @scope/a # succeeds
c:\repos\b> pnpm unlink --global @scope/a # confusing warnings and other output, maybe unrelated
c:\repos\b> pnpm link --global @scope/a  # relink attempt fails

Expected behavior:

unlinking should restore an equivalent state of the filesystem prior to the original linking.

Actual behavior:

Some kind of corruption seems to be occurring. Aside from the presence of the /pnpm-global/ folder, we might expect that the files match ~exactly some initial state? It's hard to tell because I don't know what a theoretical initial state for pnpm-global is, but it doesn't seem to be happening that way.

  • Upon unlinking (side note, superagent IS a declared dependency in @scope/b):
 WARN  @scope/a has no binaries
Progress: resolved 69, reused 69, downloaded 0, added 69, done

C:\Users\me\AppData\Roaming\npm\pnpm-global\5:
- @scope/a
+ @scope/a 5.1.0 (6.0.0 is available)

 WARN  Issues with peer dependencies found
.
└─┬ @scope/a
  └── ✕ missing peer superagent@"*"
Peer dependencies that should be installed:
  superagent@"*"
  • Upon pnpm link --global with the corruption already present:
 WARN  Local dependency not found at C:\Users\me\AppData\Roaming\npm\pnpm-global\5\node_modules\@scope\a

C:\Users\me\AppData\Roaming\npm\pnpm-global\5:
- @scope/a
Noted pnpm-global file transitions:

After linking for @scope/a --global, we still have a tidy file structure:

image

pnpm-global\5\package.json:

{
	"dependencies": {
		"@scope/a": "^5.0.0"
	}
}

pnpm-global\5\pnpm-lock.yaml:

lockfileVersion: 5.3

specifiers:
  '@scope/a': ^5.0.0

.pnpm/lock.yaml, the only file\folder there, is merely:

lockfileVersion: 5.3

specifiers: {}

After fully linking from @scope/b, pnpm-global\5\pnpm-lock.yaml and .pnpm/lock.yaml agree as:

lockfileVersion: 5.3

specifiers:
  '@scope/a': ^5.0.0

dependencies:
  '@scope/a': link:node_modules/@scope/a

after unlinking, at least one new symlink has been introduced along with a new .modules/yaml file

image

.pnpm is full of versioned package folders. pnpm-global\5\pnpm-lock.yaml and .pnpm/lock.yaml agree as:

lockfileVersion: 5.3

specifiers:
  '@scope/a': ^5.0.0

dependencies:
  '@scope/a': link:node_modules/@scope/a

packages:
   ...

The attempt to relink from @scope/b removes all of the .pmpm dependency folders and clears the dependencies list from pnpm-global\5\pnpm-lock.yaml and .pnpm/lock.yaml.

Short of removing the entire pnpm-global folder and starting over, I have not found a subset of reversions that I can make that seem to fix the corrupted state.

Additional information:

  • node -v prints: v16.14.0
  • Windows, macOS, or Linux?: Windows
@zkochan
Copy link
Member

zkochan commented May 1, 2022

Try with pnpm v7.0.0

@JasonKleban
Copy link
Author

I upgraded to pnpm 7 but I don't recognize any behavior difference.

@Carnia
Copy link

Carnia commented Jun 27, 2022

7.3.0
same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants