elm-test fails to run when `elm-explorations/test` is in both the indirect dependencies and test-dependencies
Closed this issue · 5 comments
Summary
elm-test
fails to run when elm-explorations/test
is in both the indirect dependencies (direct?) and test-dependencies.
SSCCE
# Create a new project
elm init
elm-test init
elm-test # Everything runs correctly
elm install jfmengels/elm-review
elm-test # RUN FAILURE
Here is the error message we get when running elm-test
at the end:
-- 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 /home/jeroen/dev/node-test-runner-deps-problem/tests/Example.elm
elm.json BEFORE installing jfmengels/elm-review
```json { "type": "application", "source-directories": [ "src" ], "elm-version": "0.19.1", "dependencies": { "direct": { "elm/browser": "1.0.2", "elm/core": "1.0.5", "elm/html": "1.0.0" }, "indirect": { "elm/json": "1.1.3", "elm/time": "1.0.0", "elm/url": "1.0.0", "elm/virtual-dom": "1.0.2" } }, "test-dependencies": { "direct": { "elm-explorations/test": "1.2.2" }, "indirect": { "elm/random": "1.0.0" } } } ```elm.json AFTER installing jfmengels/elm-review
```json { "type": "application", "source-directories": [ "src" ], "elm-version": "0.19.1", "dependencies": { "direct": { "elm/browser": "1.0.2", "elm/core": "1.0.5", "elm/html": "1.0.0", "jfmengels/elm-review": "2.0.2" }, "indirect": { "elm/json": "1.1.3", "elm/parser": "1.1.0", "elm/project-metadata-utils": "1.0.1", "elm/random": "1.0.0", "elm/time": "1.0.0", "elm/url": "1.0.0", "elm/virtual-dom": "1.0.2", "elm-community/json-extra": "4.2.0", "elm-community/list-extra": "8.2.4", "elm-explorations/test": "1.2.2", "rtfeldman/elm-hex": "1.0.0", "rtfeldman/elm-iso8601-date-strings": "1.1.3", "stil4m/elm-syntax": "7.1.1", "stil4m/structured-writer": "1.0.2" } }, "test-dependencies": { "direct": { "elm-explorations/test": "1.2.2" }, "indirect": {} } } ```Additional details
The problem is that elm-explorations/test
is present both in the indrect dependencies and in the direct test-dependencies. It is added because jfmengels/elm-review
depends on it, to provide tools to test the things you build with elm-review
.
Manually removing elm-explorations/test
from the indirect dependencies solves the problem, and lets elm-test
run smoothly. Hence, when I run elm-review init
which creates a very similar elm.json
to the one above, the init
subcommand manually removes it from the indirect dependencies. Without doing that, users of elm-review
are not able to test what they built with elm-review
.
This is IMO not a good solution, because whenever we install you install a dependency using elm install author/pkg
, elm-explorations/test
gets re-added to the indirect dependencies, re-introducing the issue. (I'm actually surprised the Elm compiler never complains about dependencies being manually edited).
I think the way node-test-runner
manipulates the elm.json
gets confused, and I would love this to be resolved, so that (at least) elm-review
users can have a much nicer and surprise-less experience.
References
This issue was discussed over at elm-json
: zwilias/elm-json#22
Additional notes
I have not tested whether elm-explorations/test
being in the direct dependencies causes similar problems, but I imagine that it could.
Also, this problem might happen for other packages than elm-explorations/test
being duplicated. I could imagine avh4/elm-program-test
being in the indirect dependencies for a project and in the direct test-dependencies for instance.
Thanks
Thanks a lot for all the work you put into this tool, it is a pleasure to use it ❤️
I think the solution is to use elm-json to do proper test dependency resolution. @jfmengels maybe you could weigh in at #356 .
As @zwilias told me on Slack, elm-json
is really slow offline (does it even work offline?) at the moment, so I don't think it is ready to be used in this project yet.
From using it in elm-review, I guess it could be much faster from using the "take what is available on file system".
I don't know how complex solving this particular bug would be, but I imagine it could be worth fixing it before elm-json gets ready. I'll try and take a look and see if I can make a PR.
@zwilias what do you think?
Makes sense 👍 If you do think about a PR, be warned that the dependancy solving code in this repository is very rough and ready.
I tried this on master and the error is no longer there! Must have been fixed by switching to elm-json in #451.
Fantastic