Elm-test - how to fix package dependency errors?

I’m getting the “INVALID PACKAGE DEPENDENCIES” error when trying to run elm-test on a new project. How do I find out what packages are missing / fix the error?

Story so far:

  1. Created the project with elm init
  2. Built and ran the app with parcel
  3. Iterated a bit, including installing some packages (still running via parcel - all OK)
  4. ran elm-test init which added a couple of entries to elm.json (see below).
  5. ran elm-test in the project root which produces the error.

elm.json contents as follows. I haven’t edited the file manually - all dependencies (direct & indirect) were added using elm install. Test dependencies were added by elm-test.

{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.0",
    "dependencies": {
        "direct": {
            "elm/browser": "1.0.1",
            "elm/core": "1.0.2",
            "elm/html": "1.0.0",
            "elm/http": "2.0.0",
            "elm/parser": "1.1.0"
        },
        "indirect": {
            "elm/bytes": "1.0.8",
            "elm/file": "1.0.5",
            "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"
        }
    }
}

The package docs indicate it should ‘just work’ per steps I followed. The elm-test readme on github says " Copy all the dependencies from elm-package.json into tests/elm-package.json". However that seems like it’s pre- elm 19.

Thanks for any pointers.

I would recommend using https://github.com/zwilias/elm-json (elm-json install and elm-json install --test) instead of elm install and elm-test install to install and upgrade your dependencies, since it has more correct and comprehensive resolution logic and error reporting.

2 Likes

Thanks, I’ll take a look.

As an aside, is there any way to find out what’s causing the problem though? Short of stepping through code, I’m not aware of any other way.

Hi,

I have also run into this problem before - here is how you can diagnose it.

elm-test creates another elm.json to build and run the test cases. This can be found under:

elm-stuff/generated-code/elm-explorations/test/elm.json

Paste the contents of that file into this:

https://www.markuslaire.com/github/elm-dependencies-analyzer/

and it will tell you which dependencies are not compatible and why. In your case it says:

Selected versions have dependency conflicts:

* elm/json 1.0.0
  * 1.1.0 <= v < 2.0.0 needed by elm/http 2.0.0

Somehow elm-test has replaced your indirect elm/json/1.1.3 with a direct elm/json/1.0.0.

To fix it I ran:

> elm install elm/json

which simply moved that dependency from indirect into direct.

Worth raising an issue against elm-test for this one (I did it for you): https://github.com/elm-explorations/test/issues/103

5 Likes

Wonderful - thanks @rupert. Solved both my initial question and how to be self-sufficient in future. Raising a bug is icing on the cake!

Very grateful, thanks a bunch.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.