compiler
compiler copied to clipboard
Compiler hangs forever if elm.json's dependencies field is an empty object
Quick Summary: When the elm.json's "dependencies" field is {} instead of { "direct": { ... }, "indirect": { ... } }, the compiler tries to explain the problem, but hangs in the process
SSCCE
Compile any Elm code with the following command elm make A.elm
and with the following elm.json file:
{
"type": "application",
"source-directories": [
"."
],
"elm-version": "0.19.1",
"dependencies": {},
"test-dependencies": {
"direct": {},
"indirect": {}
}
}
-- Elm code is barely important here
module A exposing (a)
a = 1
- Elm: 0.19.1
- Browser: NA
- Operating System: Linux Ubuntu 18.04
Additional Details
This is the message I get:
> elm make A.elm
Dependencies ready!
-- MISSING FIELD ------------------------------------------------------ elm.json
I ran into a problem with your elm.json file. I ran into trouble with the value
of the "dependencies" field:
Then it hangs forever and takes 100% of one of my thread's CPU until I kill the process.
For context: I get this error when trying to programmatically create an elm.json in elm-review (kind of like elm-test does it). I use elm-json to know which dependencies need to be added to elm-json, but that fails when the user has no Internet access.
I should be able to go around this problem without too much trouble, but I thought it might be useful to know that this problem exists.
Thanks for reporting this! To set expectations:
- Issues are reviewed in batches, so it can take some time to get a response.
- Ask questions a community forum. You will get an answer quicker that way!
- If you experience something similar, open a new issue. We like duplicates.
Finally, please be patient with the core team. They are trying their best with limited resources.
Here’s something interesting: If I make the following change to the SSCCE:
- "dependencies": {},
+ "dependencies": {
+ },
Then I get the expected error message with no hanging:
-- MISSING FIELD ------------------------------------------------------ elm.json
I ran into a problem with your elm.json file. I ran into trouble with the value
of the "dependencies" field:
7| "dependencies": {
^
I was expecting to run into an OBJECT with a "direct" field.
I think that the error reporting hangs whenever the JSON syntax is correct but there’s an error like “missing field” in a JSON object written on a single line.
This is the shortest reproduction I could come up with:
❯ mkdir elm-hang
❯ cd elm-hang
❯ echo '{}' > elm.json
❯ elm make
Dependencies ready!
-- MISSING FIELD ------------------------------------------------------ elm.json
I ran into a problem with your elm.json file. I ran into some trouble here:
^C^C⏎
However, if you do printf '{\n}' > elm.json instead of echo '{}' > elm.json, it does not hang:
Dependencies ready!
-- MISSING FIELD ------------------------------------------------------ elm.json
I ran into a problem with your elm.json file. I ran into some trouble here:
1| {
^
I was expecting to run into an OBJECT with a "type" field.
Note: If you’re messing around with this, don’t forget to remove the elm-stuff/ folder before each elm make run! Otherwise the bug might not occur.