# Elm-test - how to fix package dependency errors?

**URL:** https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054
**Category:** Learn
**Created:** [July 25, 2019, 4:19pm UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054 "2019-07-25T16:19:20Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sfinnie](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@sfinnie](https://discourse.elm-lang.org/u/sfinnie)
#### Post date: [July 25, 2019, 4:19pm UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/1 "2019-07-25T16:19:20Z")

</div>

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](https://package.elm-lang.org/packages/elm-explorations/test/latest/) indicate it should ‘just work’ per steps I followed. The elm-test [readme](https://github.com/elm-community/elm-test) 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.

---

<div class="post-metadata">

### Author: ![avh4](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/avh4/32/97_2.png) [@avh4](https://discourse.elm-lang.org/u/avh4)
#### Post date: [July 25, 2019, 6:44pm UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/2 "2019-07-25T18:44:04Z")

</div>

I would recommend using [https://github.com/zwilias/elm-json](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.

---

<div class="post-metadata">

### Author: ![sfinnie](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@sfinnie](https://discourse.elm-lang.org/u/sfinnie)
#### Post date: [July 26, 2019, 6:30am UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/3 "2019-07-26T06:30:50Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![rupert](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/rupert/32/1775_2.png) [@rupert](https://discourse.elm-lang.org/u/rupert)
#### Post date: [July 26, 2019, 8:56am UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/4 "2019-07-26T08:56:23Z")

</div>

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](https://github.com/elm-explorations/test/issues/103)

---

<div class="post-metadata">

### Author: ![sfinnie](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@sfinnie](https://discourse.elm-lang.org/u/sfinnie)
#### Post date: [July 26, 2019, 1:31pm UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/5 "2019-07-26T13:31:42Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)
#### Post date: [August 5, 2019, 1:31pm UTC](https://discourse.elm-lang.org/t/elm-test-how-to-fix-package-dependency-errors/4054/6 "2019-08-05T13:31:46Z")

</div>

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