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

More helpful message when command doesn't exist? #6492

Closed
1 task done
JoshuaKGoldberg opened this issue May 1, 2023 · 1 comment · Fixed by #6496
Closed
1 task done

More helpful message when command doesn't exist? #6492

JoshuaKGoldberg opened this issue May 1, 2023 · 1 comment · Fixed by #6496

Comments

@JoshuaKGoldberg
Copy link
Contributor

Describe the user story

When someone runs pnpm run with a non-existent command, the current error message is not very informative:

$ pnpm run buil
 ERR_PNPM_NO_SCRIPT  Missing script: buil

Similar with just pnpm and the command:

$ pnpm buil
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with ENOENT: buil
spawn buil ENOENT

Many users wouldn't know what ENOENT is. It'd be nice to have a more explicit message saying what went wrong.

Describe the solution you'd like

How about:

  • Explicitly saying in plain text that the command is missing
  • If a similar command exists, suggesting it
$ pnpm run buil
 ERR_PNPM_NO_SCRIPT  Missing script: buil
Command "buil" not found. Did you mean "pnpm run build"?
$ pnpm buil
 ERR_PNPM_RECURSIVE_EXEC_FIRST_FAIL  Command failed with ENOENT: buil
Command "buil" not found. Did you mean "pnpm run build"?

Describe the drawbacks of your solution

...it's less technically precise, I suppose? Feels very pure-positive as a change to me. 🤷

Describe alternatives you've considered

Here's what npm outputs:

$ npm run buil
npm ERR! Missing script: "buil"
npm ERR! 
npm ERR! Did you mean this?
npm ERR!     npm run build # run the "build" package script
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/josh/.npm/_logs/2023-05-01T19_10_14_940Z-debug-0.log
$ npm buil
Unknown command: "buil"

Did you mean this?
    npm run build # run the "build" package script

To see a list of supported npm commands, run:
  npm help

...and here's Yarn v1:

$ yarn run buil
yarn run v1.22.19
error Command "buil" not found. Did you mean "build"?
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ yarn buil
yarn run v1.22.19
error Command "buil" not found. Did you mean "build"?
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@zkochan
Copy link
Member

zkochan commented May 2, 2023

For pnpm run buil it makes sense.

I am not sure about pnpm buil though. pnpm buil is actually running pnpm exec buil in case there is no script with the name buil. So for this case the error kinda makes sense. Yarn has the same behaviour but they print a better error message, so I guess they parse the error and print it only for specific types of errors.

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

Successfully merging a pull request may close this issue.

2 participants