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: add path to package.json in error message #456

Merged
merged 4 commits into from
Apr 15, 2024

Conversation

aduh95
Copy link
Contributor

@aduh95 aduh95 commented Apr 13, 2024

I had to help someone who couldn't understand why they were getting this error message on an empty directory; turned out they had a package.json in their home directory (no idea how it got there) that defined a packageManager field. I think adding some explanation would help.

@arcanis
Copy link
Contributor

arcanis commented Apr 13, 2024

no idea how it got there

That's an issue we sometimes have with yarnPath as well. Perhaps we should make corepack use fail if run in the home directory, unless a special CLI flag is set (like rm --no-preserve-root)?

@aduh95 aduh95 enabled auto-merge (squash) April 13, 2024 11:18
sources/Engine.ts Outdated Show resolved Hide resolved
tests/main.test.ts Outdated Show resolved Hide resolved
Co-authored-by: Steven <steven@ceriously.com>
@aduh95 aduh95 merged commit 32a93ea into main Apr 15, 2024
10 checks passed
@aduh95 aduh95 deleted the packge.json-in-error-message branch April 15, 2024 18:17
@@ -419,7 +420,10 @@ it(`should refuse to run a different package manager within a configured project
process.env.FORCE_COLOR = `0`;

await expect(runCli(cwd, [`pnpm`, `--version`])).resolves.toMatchObject({
stdout: `Usage Error: This project is configured to use yarn\n\n$ pnpm ...\n`,
stdout: `Usage Error: This project is configured to use yarn because ${
// ppath and xfs do not format Windows correctly, the regex fixes that:
Copy link
Member

Choose a reason for hiding this comment

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

You would use npath.fromPortablePath to handle that.

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

Successfully merging this pull request may close these issues.

None yet

4 participants