Open andys8 opened 5 years ago
Ran into this issue again, today. It is still the case with 0.19.1
. It is not the case if zwilias/elm-json
is used to install packages instead of the elm compiler.
https://github.com/andys8/elm-compiler-incompatible-test-dependency-demo
elm-test will work
npx elm-test@latest-0.19.0 --compiler /home/ascharf/bin/elm-0.19.0
-- INVALID PACKAGE DEPENDENCIES --------------------------------------- elm.json
The dependencies in your elm.json are not compatible.
Did you change them by hand? Try to change it back! It is much better to add
dependencies with elm install or the dependency management tool in elm reactor.
Please ask for help on the Elm slack <http://elmlang.herokuapp.com/> if you try
those paths and still cannot figure it out!
Compilation failed while attempting to build /tmp/elmjson/tests/MyTest.elm
$ elm-test
-- ERROR IN DEPENDENCIES ---------------------------------------------- elm.json
It looks like the dependencies elm.json in were edited by hand (or by a 3rd
party tool) leaving them in an invalid state.
Try to change them back to what they were before! It is much more reliable to
add dependencies with elm install or the dependency management tool in
elm reactor.
Please ask for help on the community forums if you try those paths and are still
having problems!
Compilation failed while attempting to build /tmp/elmjson/tests/MyTest.elm
The issue is elm
adding this indirect dependency. elm-json
doesn't do that.
Note: elm.json
pretty printed for better diffs
Technically elm
is correct and elm-json
is wrong here. elm/html
is a dependency of elm/browser
, so it should be in your indirect dependencies: it is necessary to build your application in non-test mode. elm-json
wrongly filters it out. I should look into that, I suppose.
I think when all is said and done, the issue here is that elm-test
fails to run, given a valid elm.json file...
Interesting! Thanks for the input.
So, based on this explanation, a guess would be the actual issue being elm-test
merging direct test dependency elm/html
with indirect build dependency elm/html
leading to elm compiler failing to compile?
Yeah, elm-test
sort of blindly merges together dependencies, with the end result (in this instance) having both a direct and an indirect dependency on elm/html
. The compiler notices that this is rather fishy and rejects the generated elm.json. I'm pretty sure one of the issues linked from https://github.com/rtfeldman/node-test-runner/pull/356 will be about the same thing!
Issue
It's possible to run
elm install <package>
and the resultingelm.json
can't be used. The compiler will fail with "The dependencies in your elm.json are not compatible."Reproduce issue
Valid
elm.json
Steps
ryannhg/date-format
by hand (this done, because there is currently no other way to update)elm install ryannhg/date-format
rm -rf elm-stuff
elm-test
(looks like building the app is still working)Resulting invalid
elm.json
What happenend?
"elm/html": "1.0.0"
was added todependencies.indirect
. But it's also existing intest-dependencies.direct
. Removing it fromdependencies.indirect
by hand will resolve the issue.It is intentional to not have the dependency
elm/html
in thesrc
. It should not be used by accident. It is necessary for testing though.