Tailwind CLI outputs build stats to STDERR, causing certain build systems to treat successful builds as failures
See original GitHub issueWhat version of Tailwind CSS are you using?
3.0.23
What build tool (or framework if it abstracts the build tool) are you using?
Tailwind CLI (npx tailwind
)
What version of Node.js are you using?
16.14.2
What browser are you using?
N/A
What operating system are you using?
Linux (GH Codespaces)
Reproduction URL
https://github.com/eldarshamukhamedov/repro-tailwindcss-stderr/tree/main
Steps:
- Install NPM dependencies
npm install
- Run
npm run build
to confirm there are no errors - Run
npm run build 2>stderr.txt
to pipe the build STDERR output to thestderr.txt
file
Expected:
- A successful build does not output anything to STDERR (
stderr.txt
file is empty)
Actual:
- A successful build outputs “Done in XXms.” to STDERR (
stderr.txt
file contains “Done in XXms.”)
Describe your issue
Some build systems (RushJS) treat any output to STDERR as a failed build, regardless of the process exit code.
From the repro steps above, you can see that tailwind
build succeeds, and the process terminates with a clean exit code, but tailwind
outputs the “Done in XXms.” string to STDERR, not STDOUT.
Since any output to STDERR implies that something went wrong, some build systems (e.g. RushJS) will assume the build failed.
Proposed solution
Output the build stats string (“Done in XXms”) to STDOUT, instead of STDERR. Continue to output actual build errors to STDERR.
Workarounds considered
It is possible to write a bash script that reads tailwind
STDERR output, checks that the only output is the build stats string, and then “swallows” the output. The script would need to carefully parse the overall STDERR output and continue to output actual errors to STDERR. It’s doable, but a bit tricky.
Issue Analytics
- State:
- Created a year ago
- Comments:5 (1 by maintainers)
I’m going to close this since this behavior is not something we are likely to change but have made a note about the
--silent
option idea which I think definitely has value 👍🏻 Hopefully the solutions discussed here are helpful in the mean time, and thanks for the idea!The problem here is that stderr is not just for errors. Writing to stderr does not mean there is a failure. The documentation for stderr states explicitly that you can use it for diagnostic messages and warnings. You don’t (usually) print diagnostic messages to stdout because they’re not part of the normal output of the program. I’d say that RushJS is handling this incorrectly. They have a few open issues about this causing problems even for their own CI builds. As a workaround it appears you can set
allowWarningsInSuccessfulBuild
to true and Rush will let the build succeed.A
--silent
flag or--level
option could be a useful feature to have though.