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

[Feature] Add --silent back #3542

Closed
nfantone opened this issue Oct 8, 2021 · 10 comments
Closed

[Feature] Add --silent back #3542

nfantone opened this issue Oct 8, 2021 · 10 comments
Labels
enhancement New feature or request stale Issues that didn't get attention waiting for feedback Will autoclose in a while unless more data are provided

Comments

@nfantone
Copy link
Contributor

nfantone commented Oct 8, 2021

Describe the user story

IMO, this was an important feature, heavily requested for the original yarn. Not sure why it was taken out. Really useful for CI environments and a no-brainer for most CLI tools out there. As an example, this is how a fairly typical CI log would look for us, making it really hard to mentally parse and navigate.

11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide @bubble-dev/typescript-config (p8fd76), requested by @bubble-dev/types
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide lottie-ios (pdcaff), requested by @company/molecule-loader
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide lottie-react-native (p05561), requested by @company/molecule-loader
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide prop-types (pf82f5), requested by proper-types
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide prop-types (p9eab9), requested by @company/higher-order-components
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide ramda (pde188), requested by @company/particle-colors
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide ramda (pb2e74), requested by @company/atom-spacer-horizontal
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide ramda (pcebba), requested by @company/atom-spacer-vertical
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide ramda (pacec0), requested by @company/primitive-motion
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide ramda (p40221), requested by @company/molecule-link-detail
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide react-context-props (p367ba), requested by @company/higher-order-components
11:23:44  ➤ YN0002: │ @company/molecule-masked-field@npm:0.23.1::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-masked-field%2F-%2F%40bubble-ui%2Fmolecule-masked-field-0.23.1.tgz [d5ba3] doesn't provide react-motion (pb0cbc), requested by @company/primitive-motion
11:23:44  ➤ YN0002: │ @company/molecule-mega-paragraph@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-paragraph%2F-%2F%40bubble-ui%2Fmolecule-mega-paragraph-0.17.0.tgz [d5ba3] doesn't provide prop-types (p4e34a), requested by proper-types
11:23:44  ➤ YN0002: │ @company/molecule-mega-paragraph@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-paragraph%2F-%2F%40bubble-ui%2Fmolecule-mega-paragraph-0.17.0.tgz [d5ba3] doesn't provide ramda (p8c8c8), requested by @company/particle-colors
11:23:44  ➤ YN0002: │ @company/molecule-mega-paragraph@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-paragraph%2F-%2F%40bubble-ui%2Fmolecule-mega-paragraph-0.17.0.tgz [d5ba3] doesn't provide ramda (paad60), requested by @company/hoc-with-debug-mode
11:23:44  ➤ YN0002: │ @company/molecule-mega-title-display@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-title-display%2F-%2F%40bubble-ui%2Fmolecule-mega-title-display-0.17.0.tgz [d5ba3] doesn't provide prop-types (pb11c2), requested by proper-types
11:23:44  ➤ YN0002: │ @company/molecule-mega-title-display@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-title-display%2F-%2F%40bubble-ui%2Fmolecule-mega-title-display-0.17.0.tgz [d5ba3] doesn't provide ramda (p38edc), requested by @company/particle-colors
11:23:44  ➤ YN0002: │ @company/molecule-mega-title-display@npm:0.17.0::__archiveUrl=https%3A%2F%2Fartifactory.company.net%2Fartifactory%2Fapi%2Fnpm%2Fv-npm-production%2F%40bubble-ui%2Fmolecule-mega-title-display%2F-%2F%40bubble-ui%2Fmolecule-mega-title-display-0.17.0.tgz [d5ba3] doesn't provide ramda (p7e63e), requested by @company/hoc-with-debug-mode
# ...

As far as I could gather, --silent was added as a "hidden" flag for compatibility purposes - but doesn't really do anything. This is bound to trip people up.

Describe the solution you'd like

yarn --silent should not print anything at all and return the appropriate status code.

Describe alternatives you've considered

Right now, we are adding a bunch of general exclusions in .yarnrc.yml as logFilters for each project. Maybe those could be exposed as CLI flags?

@nfantone nfantone added the enhancement New feature or request label Oct 8, 2021
@arcanis
Copy link
Member

arcanis commented Oct 8, 2021

The --silent flag was a blanket flag that couldn't be controlled; the direction now goes more into letting you decide exactly what you want to ignore (using logFilters).

@arcanis arcanis added the waiting for feedback Will autoclose in a while unless more data are provided label Oct 8, 2021
@nfantone
Copy link
Contributor Author

nfantone commented Oct 8, 2021

That makes sense. Except there's no way to toggle those on and off on demand, besides manually editing .yarnrc.yml. Am I correct?

It'd be really useful if we could, say, make the CI logs silent but have every other install output be normal. Additionally, I don't see a way of replicating the behaviour of the old --silent with logFilters. This, I believe, would be the closest, but doesn't work unfortunately:

logFilters:
  - pattern: *
    level: discard

@arcanis
Copy link
Member

arcanis commented Oct 8, 2021

Environment configuration doesn't support complex variable types at the moment, but you can use the cli:

yarn config set logFilters --json '[{"pattern": "*", "level": "discard"}]'

Btw, regarding the logs you shown, seems like most of them come from ramda. Perhaps it'd be easier to address them by either providing it (if necessary) or marking it as an optional peer dependency (if not), either upstream or via packageExtensions?

The archiveUrl parts are caused by your custom registry (artifactory) not using a standard pattern for tarballs (/scope/name/-/name-version.tgz). Perhaps that's something you can raise on their side? I don't know if they are aware of this issue.

@nfantone
Copy link
Contributor Author

nfantone commented Oct 8, 2021

Yeah - I'm aware of what the logs are saying. Thanks for pointing that out, but this is not what this issue is about, really.

Like I mentioned before, the pattern: * solution doesn't work (requires at least one character that is not a wildcard). And also yarn config set logFilters --json '[{"pattern": "*", "level": "discard"}]' seems awfully verbose and awkward when all we'd like is --silent.

@davwheat
Copy link
Contributor

davwheat commented Oct 9, 2021

I'd like to use --silent to clean up my docker container build process. Just receiving a success or fail is good enough -- I can always troubleshoot manually.

I don't want to blanket-silence all the time, but only for one specific use case, which (I don't think) is possible at the moment.

@nfantone
Copy link
Contributor Author

nfantone commented Oct 11, 2021

Agree with @davwheat here. Environments such as Docker and CI/CD were the main use cases for the addition of --silent in v1.

@arcanis I've been thinking about this:

The --silent flag was a blanket flag that couldn't be controlled;

Isn't that the exact reason why it was useful in the first place? When applying this kind of logging control flags, like --quiet, --verbose or --silent, having a dedicated, aptly named option for quickly altering the output is the right way to think about them. Giving users finer controls on that is great, but it should not come at the detriment of what is arguably the most common scenario you'd want to apply those controls in, anyway.

@bgotink
Copy link
Sponsor Member

bgotink commented Nov 7, 2021

yarn --silent should not print anything at all and return the appropriate status code.

Isn't this exact behaviour achievable using yarn >/dev/null? (assuming any major *NIX shell, not sure what the alternative is in CMD or PowerShell)
In other words, if the target is to remove all output, doing so is trivial if you have control over how the command is executed. Is there a specific reason having a --silent flag would be preferable over controlling the process's output directly via a redirect?

Here are a couple of reasons why adding a --silent flag for this behaviour might not be a good idea:

  • Shell redirects are more powerful than a --silent flag.
    For example, it's entirely possible to redirect yarns output to a file and then store that file in your CI/CD pipeline to make it easier to investigate yarn's output in case a build fails.
    If yarn wanted to support that behaviour on its own, it'd need an extra --output option to redirect output to a file. Next we might want to add an --stderr flag to log to stderr instead of stdout, or even more flags if you're introducing extra output streams in your commands.
  • Shell redirects are more universal than a --silent flag.
    Not only is this flag named --quiet in some other commands (e.g. npm, git diff, and yarn dlx), many commands don't have a flag to quiet their output in the first place (e.g. diff, prettier, and brew to name a few, or BASH builtins like pushd/popd/command).
    Redirects, meanwhile, work regardless of what is being executed.
  • Shell redirects are less ambiguous than a --silent flag.
    Does a --silent/--quiet flag make the command output nothing at all or does it tell it to output only "important" logging? Some commands have multiple levels of quiet (e.g. apt -q vs apt -qq). These quiet flags might even change the program's behaviour, e.g. git diff exits with exit code 0 if it finds a difference whereas git diff --quiet exits with code 1.
    Seeing some-command >/dev/null 2>&1, on the other hand, means you can tell this command will never output anything to the console without having to look up any manpage or --help output.

This isn't to say there aren't commands where a --silent/--quiet flag has tangible benefits. There's grep and git diff, which may be able to stop early if all you care about is whether a match or difference has been found. An other example is yarn dlx, where you might want to silence only yarn's logging but allow the executed command's output to come through.
There are, as I currently see it, no such benefits to adding a silent/quiet flag to yarn install.

@yarnbot
Copy link
Collaborator

yarnbot commented Dec 7, 2021

Hi! 👋

It seems like this issue as been marked as probably resolved, or missing important information blocking its progression. As a result, it'll be closed in a few days unless a maintainer explicitly vouches for it.

@yarnbot yarnbot added the stale Issues that didn't get attention label Dec 7, 2021
@yarnbot yarnbot closed this as completed Dec 12, 2021
@nfantone
Copy link
Contributor Author

@bgotink Yeah, no. That's not really portable.

@andrew-aladjev
Copy link

I am just disabling annoying and meaningless messages:

yarn config set logFilters --json '[
  {
    "code": "YN0007",
    "level": "discard"
  },
  {
    "code": "YN0008",
    "level": "discard"
  },
  {
    "code": "YN0013",
    "level": "discard"
  },
  {
    "code": "YN0018",
    "level": "discard"
  },
  {
    "code": "YN0019",
    "level": "discard"
  },
  {
    "code": "YN0061",
    "level": "discard"
  }
]' > /dev/null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request stale Issues that didn't get attention waiting for feedback Will autoclose in a while unless more data are provided
Projects
None yet
Development

No branches or pull requests

6 participants