Skip to content

detectPnpmMajor checks cwd instead of target path #1306

Description

@sacrosanctic

If you're working on this repo and runs pn build && pn sv ../test --install pnpm. It will create a onlyBuiltDependencies instead of allowBuilds because this repo is using pnpm 10.

"packageManager": "pnpm@10.33.4+sha512.1c67b3b359b2d408119ba1ed289f34b8fc3c6873412bec6fd264fbdc82489e510fcbecb9ce9d22dae7f3b76269d8441046014bdca53b9979cd7a561ad631b800"

This can be generalized to any situation where the cwd and the target doesn't have matching versions via https://pnpm.io/package_json#devenginespackagemanager.

It was also bugged on the pnpm side where child process will inherit the parent version but is now fixed.

proposed fix

  • pass in cwd allowBuilds(packages,{cwd})
  • make the versions explicit allowBuilds(packages, {pnpmVersion})
  • default to os.tmpdir()

os.tmpdir() will not fix pnx sv add ..., only pnx sv create ....

export function detectPnpmMajor(): number | undefined {
	try {
		const out = execSync('pnpm --version', {
			encoding: 'utf-8',
			stdio: ['ignore', 'pipe', 'ignore'],
+			cwd: os.tmpdir()
		});
		return coerceVersion(out.trim()).major;
	} catch {
		return undefined;
	}
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions