-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
yarn run --silent
doesn't suppress yarn's stderr
#5359
Comments
@zevdg Why would you want to hide errors? Isn't the real solution here to handle the errors in your script? |
Did you fully read the initial description? I thought there was enough information there to answer this question, but I can try to articulate it more clearly. First off, I'm not suggesting that ALL of the error output should be hidden. Simply the commands (generally sub-commands) run with the --silent flag. Because output like
is redundant and unhelpful. I hope we can agree on that much. Imagine you have a script "foo" which calls a script "bar" which calls a script "baz" which calls a script "qux". If qux fails, I would get the output above. Ideally, i'd want something like
but barring that enhancement, I'll settle for a single
output from yarn itself and then I'd modify my scripts to log their own failures more verbosely. In npm, this can be easily achieved by using the --silent flag when calling one script from another script, but in yarn, the silent flag doesn't work the same way. In yarn, there is no good way to achieve this.
I'm not sure what you're even suggesting by this. Could you please give me a concrete example.
How do you suggest I change these 2 scripts to "handle the errors". The whole point of the "git-is-clean" script is to fail when there are uncommitted changes. It is a helper script that is meant to be called by other yarn scripts to prevent them from being executed on an "unclean" working directory. I see no good way for it to do that without getting the useless duplicate error output from yarn. |
@zevdg This makes more sense, i overlooked the focus on redundancy. Ok you win. have a 🌮 |
As mentioned in #5440, this is a common use case when you have a linter or test runner command specified in your package.json. These commands return non-zero exit codes when you're working on the code, and you don't need yarn to report anything else. |
I am also experiencing this with |
@Wilfred you can get around this by doing something really hacky like I'd really like a way to trigger
I tried something like
but since it's broken anyway, it's difficult to tell whether you can attach flags to secondary commands (i.e. ones that are short for |
I would especially like to be able to suppress yarn's echoing of the original command to stderr when an error occurs. In particular for use in CI/CD situations where a deployment target requires logging into the upstream server, as at present yarn echoes the values of the username and password fields (set via env variables) to the error output. Sending stderr to /dev/null means that you also miss the 'Invalid login' message.
Out of the above, the only message that should be coming back is the |
This is also affecting
This is very verbose and confusing for users when |
I made a minimal patch in #7472 🤷♂ I'm actually coming from #5440 so my perspective is that a |
* Do not log `err.message` of `ProcessTermError`s if silent Fixes #5359 * Ensure `YARN_SILENT=0` by default in the integration tests
* Do not log `err.message` of `ProcessTermError`s if silent Fixes yarnpkg#5359 * Ensure `YARN_SILENT=0` by default in the integration tests
* Do not log `err.message` of `ProcessTermError`s if silent Fixes yarnpkg#5359 * Ensure `YARN_SILENT=0` by default in the integration tests
Do you want to request a feature or report a bug?
bug
What is the current behavior?
yarn run --silent
doesn't suppress stderrIf the current behavior is a bug, please provide the steps to reproduce.
for example, imagine this script section of a package.json file
If the working directory is not clean, the output of
yarn run deploy
would beNote the duplicated
error Command failed with exit code 1.
Every level of nesting that fails will add one of these lines.
If the output showed which command failed, I could sorta see this being a feature and not a bug.
For example
But as is, it's just clutter.
What is the expected behavior?
If the working directory is not clean, the output of
yarn run deploy
should beWorkarounds
FWIW, npm --silent does squelch stderr as expected, so i can "solve" this problem by using
npm run --silent
instead ofyarn run --silent
inside my scripts, but it feels dirty to have yarn call npm.Alternatively, in some cases, I could do
yarn run --silent foo 2>/dev/null
, but that would hide stderr from thefoo
script output so it isn't always an option.Please mention your node.js, yarn and operating system version.
yarn v1.3.2
node v8.9.4
os Solus 3 - linux 4.14.18
The text was updated successfully, but these errors were encountered: