Open Janiczek opened 2 years ago
Thanks for reporting this! To set expectations:
Finally, please be patient with the core team. They are trying their best with limited resources.
Are your sure both of those messages (the readable part and the JSON) are written to the same output stream? Usually the message part could be written to stdout while the json part is written to stderr (or vice versa).
Yes, both are written to stderr:
~/stuff
❯ mkdir elm-error
~/stuff
❯ cd elm-error
~/stuff/elm-error
❯ yes | elm init >/dev/null
~/stuff/elm-error
❯ printf 'module Dummy exposing (dummy)\ndummy = ()' > src/Dummy.elm
~/stuff/elm-error
❯ elm make --report=json src/Dummy.elm
~/stuff/elm-error
❯ truncate -s 1024 elm-stuff/0.19.1/i.dat
~/stuff/elm-error
❯ elm make --report=json src/Dummy.elm > stdout.txt 2> stderr.txt
~/stuff/elm-error
❯ bat stdout.txt stderr.txt
───────┬─────────────────────────────────────────────────────────────────────────────────
│ File: stdout.txt <EMPTY>
│ Size: 0 B
───────┴─────────────────────────────────────────────────────────────────────────────────
───────┬─────────────────────────────────────────────────────────────────────────────────
│ File: stderr.txt
│ Size: 852 B
───────┼─────────────────────────────────────────────────────────────────────────────────
1 │ +-------------------------------------------------------------------------------
2 │ | Corrupt File: /Users/lydell/stuff/elm-error/elm-stuff/0.19.1/i.dat
3 │ | Byte Offset: 1024
4 │ | Message: not enough bytes
5 │ |
6 │ | Please report this to https://github.com/elm/compiler/issues
7 │ | Trying to continue anyway.
8 │ +-------------------------------------------------------------------------------
9 │
10 │ {"type":"error","path":null,"title":"CORRUPT CACHE","message":["It looks like some of the information cached in elm-stuff/ has been corrupted.\n\nTry deleting your elm
│ -stuff/ directory to get unstuck.\n\n",{"bold":false,"underline":true,"color":null,"string":"Note"},": This almost certainly means that a 3rd party tool (or editor plu
│ gin) is\ncausing problems your the elm-stuff/ directory. Try disabling 3rd party tools\none by one until you figure out which it is!"]}
───────┴─────────────────────────────────────────────────────────────────────────────────
In my experience, this happens whenever elm
prints one of those “boxes”:
+---------------
| something
+---------------
Ah, I see 😢
So what is a proposed solution? Print the error in the json format to the stdout? Or somehow remove those additional messages? The first one is solveable in changing literally 3 symbols in the source code
I imagine if --report=json
is active, all the output should be those JSON lines. The +
-boxed message shouldn't be shown.
An alternative is to send some of it to stdout and some of it to stderr, so that one of the streams still is purely JSON.
Quick Summary:
elm make --report=json
sometimes emits errors in a non-JSON format, breaking tools like@parcel/transformer-elm
: (EDIT: they pick a second line and JSON.parse it)