yarnpkg / yarn

The 1.x line is frozen - features and bugfixes now happen on https://github.com/yarnpkg/berry
https://classic.yarnpkg.com
Other
41.43k stars 2.72k forks source link

yarn should use stderr for debugging output #2182

Open mgol opened 7 years ago

mgol commented 7 years ago

Do you want to request a feature or report a bug?

A bug (I think).

What is the current behavior?

Yarn prints everything to stdout, including debugging info not related to the command output.

If the current behavior is a bug, please provide the steps to reproduce.

$ yarn info angular dist-tags 2>/dev/null
yarn info v0.18.0
{ latest: '1.5.9',
  old: '1.2.32',
  previous_1_4: '1.4.14',
  next: '1.6.0-rc.2' }
✨  Done in 0.49s.
$ yarn tag ls angular 2>/dev/null
yarn tag v0.18.0
[1/3] Logging in...
[2/3] Getting tags...
info Package angular
info latest: 1.5.9
info old: 1.2.32
info previous_1_4: 1.4.14
info next: 1.6.0-rc.2
[3/3] Revoking token...
info Not revoking login token, specified via config file.
✨  Done in 1.62s.

What is the expected behavior?

I'd expect the above output to appear only if we skip the redirection (2>/dev/null). Otherwise, I'd like it to behave like that:

$ yarn info angular dist-tags 2>/dev/null
{ latest: '1.5.9',
  old: '1.2.32',
  previous_1_4: '1.4.14',
  next: '1.6.0-rc.2' }
$ yarn tag ls angular 2>/dev/null
info Package angular
info latest: 1.5.9
info old: 1.2.32
info previous_1_4: 1.4.14
info next: 1.6.0-rc.2

This is also how npm behaves (tried with npm 3.10.9):

$ npm dist-tag ls angular --loglevel=http
npm http request GET https://registry.npmjs.org/-/package/angular/dist-tags
npm http 200 https://registry.npmjs.org/-/package/angular/dist-tags
latest: 1.5.9
next: 1.6.0-rc.2
old: 1.2.32
previous_1_4: 1.4.14
$ npm dist-tag ls angular --loglevel=http 2>/dev/null
latest: 1.5.9
next: 1.6.0-rc.2
old: 1.2.32
previous_1_4: 1.4.14

Please mention your node.js, yarn and operating system version.

Node.js 6.9.2, yarn 0.18.0, macOS 10.12.1 (16B2555)

leoluk commented 6 years ago

This breaks any script which expects formatted output on stdout.

jchook commented 4 years ago

I second this proposal.

Outputting to stdout breaks generally expected command-line behavior, e.g. if you run...

yarn webpack --profile --json > profile.json

profile.json will contain some yarn debug information at the top and bottom of a 90MB JSON file.

aspiers commented 2 years ago

Indeed, this current violation is a violation of the UNIX way which expects tools to be composable via pipelines.

adrian-gierakowski commented 1 month ago

yes please