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

fix: pnpm is already installed in the current workspace and does not work. #1475

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/src/eslint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,12 @@ export namespace ESLint {
pnpm: {
cache: undefined,
get(): string {
const pnpmPath = execSync('pnpm root -g').toString().trim();
let pnpmPath: string;
try {
pnpmPath = execSync('pnpm root -g').toString().trim();
} catch {
pnpmPath = execSync('pnpm root').toString().trim();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you enclosed that as a catch to avoid any behavior breaking change. But unless we want to make that a customizable settings to force global pnpm use instead of local one, I don't think this is necessary, is it?

I would simply remove the -g flag from the original source.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly what I'm saying ;). Since pnpm root will always return the path, there is no need to keep the pnpm root -g line.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's exactly what I'm saying ;). Since pnpm root will always return the path, there is no need to keep the pnpm root -g line.

When you don't have pnpm installed locally, executing pnpm root will return a non-existent path, which will cause a more serious error.

Unless there is a better way to fix this problem, we must use pnpm root -g as a preference.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dunqing What about checking if the local path exists and falling back to pnpm root -g? 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Dunqing What about checking if the local path exists and falling back to pnpm root -g? 🤔

Sounds good.

}
return pnpmPath;
}
}
Expand Down