# Updating dependencies is not straightforward

**URL:** <https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528>\
**Category:** Request Feedback\
**Created:** [April 21, 2019, 9:52pm UTC](https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528 "2019-04-21T21:52:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Namek](https://avatars.discourse-cdn.com/v4/letter/n/6a8cbe/32.png) [@Namek](https://discourse.elm-lang.org/u/Namek)\
**Post date:** [April 21, 2019, 9:52pm UTC](https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528/1 "2019-04-21T21:52:03Z")

</div>

So after a long time I have looked into my app for further development, and it turned out that I had to update a single package in my project. The experience is sooo bad.

The Elm is 0.19, the OS is Win10. The package is **dillonkearns/elm-graphql**. The version was 1.1.0. The latest is 4.2.1, I’m gonna get it.

1. I type `elm install dillonkearns/elm-graphql@4.2.1` and I get:

> elm: TODO show possible arg configurations  
> CallStack (from HasCallStack):  
> error, called at ui/terminal/src\Terminal\Args\Error.hs:281:13 in main:Terminal.Args.Error

1. Alright, I modify the `elm.json` file by manually changing the version. What should I type in to download it? `elm install`, maybe?

> – INSTALL WHAT? ---------------------------------------------------------------
> 
> I am expecting commands like:
> 
> elm install elm/http  
> elm install elm/json  
> elm install elm/random
> 
> Hint: In JavaScript folks run `npm install` to start projects. “Gotta download  
> everything!” But why download packages again and again? Instead, Elm caches  
> packages in C:\Users\Namek\AppData\Roaming\elm so each one is downloaded and  
> built ONCE on your machine. Elm projects check that cache before trying the  
> internet. This reduces build times, reduces server costs, and makes it easier to  
> work offline. As a result elm install is only for adding dependencies to  
> elm.json, whereas elm make is in charge of gathering dependencies and building  
> everything. So maybe try elm make instead?

But wait, `elm install --help` says this:

> The `install` command fetches packages from [https://package.elm-lang.org](https://package.elm-lang.org) for  
> use in your project:
> 
> elm install  
> elm install

1. So, `elm install --help` says I could type in `elm install` and the `elm install` says we’re antagonizing the ways of “JavaScript folks”. “So maybe try `elm make` instead?”, it says.

> – INVALID PACKAGE DEPENDENCIES --------------------------------------- elm.json
> 
> The dependencies in your elm.json are not compatible.

Well, tell me more about it! But no, it won’t. “not compatible” is all I’ll get.

> 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.

Surely, I did it by hand. No, it is not much better, `elm install` does not work. I can’t upgrade the package.

```auto
Please ask for help on the Elm slack <http://elmlang.herokuapp.com/> if you try
those paths and still cannot figure it out!

```

WHAT?

1. Manually editing the `elm.json` once again, now removing the dependency from the list. Then I do `elm install dillonkearns/elm-graphql` and I get the version 1.3.0. Remember, I started with 1.1.0 and wanted 4.2.1. What happened? No info at this point.

2. The problem was already touched on the forum, right here:

> [@How do your upgrade a package in your app](https://discourse.elm-lang.org/t/how-do-your-upgrade-a-package-in-your-app/2505):
>
> When a package is outdated elm.json, what is the correct way to upgrade it? At the moment I will just change the version there. But when doint elm make, the compiler complains with: 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. (Removing elm-stuff didn’t help, when changing the version manually) So instead I tried: elm install …

No solutions that would work both for the author and for me. No improvements since then, I guess.

1. After lots of googling around I’ve found this tool helped me a lot with figuring out what versions I’m gonna need to change for updating the dependency:

[https://www.markuslaire.com/github/elm-dependencies-analyzer/](https://www.markuslaire.com/github/elm-dependencies-analyzer/) linked from here:  
[Dependencies analyzer for application elm.json - #9 by jxxcarlson](https://discourse.elm-lang.org/t/dependencies-analyzer-for-application-elm-json/2654/9)

By the way, it’s brilliant and awesome!

1. Alright, I’ll do all the modifications and now what? `elm install` will make me remember “JavaScript folks”, not do the right thing. `elm make`, maybe?

```auto
 Starting downloads...

  + elm/http 2.0.0
  + elm/json 1.1.3
  + krisajenkins/remotedata 6.0.1
  + elm/bytes 1.0.8
  + elm/core 1.0.2
  + elm/file 1.0.5
  + dillonkearns/elm-graphql 4.2.1

Dependencies ready!
-- NO INPUT --------------------------------------------------------------------

What should I make though? I need more information, like:

    elm make src/Main.elm
    elm make src/This.elm src/That.elm

However many files you give, I will create one JS file out of them.

```

Yes! It downloaded it. And gave me the same information it always does when I simply hit the `elm make` about having NO INPUT. I thought that every command has a single function. But here I can see that `elm make` can download things and compile things. That was very disinforming until I managed to actually download anything, after correcting dependencies. I couldn’t download things before because there were conflicts between dependency versions and of course I didn’t get any info nor help about those version and/or conflicts.

So it is. Lots of time lost.

---

<div class="post-metadata">

**Author:** ![ilias](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/ilias/32/6_2.png) [@ilias](https://discourse.elm-lang.org/u/ilias)\
**Post date:** [April 21, 2019, 10:41pm UTC](https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528/2 "2019-04-21T22:41:59Z")

</div>

In the long term, dependency management things will likely be much improved in the core toolchain.

In the shorter term, I’m working on a little experimental tool to hopefully make this type of stuff easier.

I hope to do an initial release somewhere in the next couple of days. Tiny demo, to illustrate how this sort of situation could be resolved:

Let’s say I have an application `elm.json` like so:

```json
{
    "type": "application",
    "source-directories": [
        "src"
    ],
    "elm-version": "0.19.0",
    "dependencies": {
        "direct": {
            "elm/core": "1.0.0",
            "elm/http": "1.0.0"
        },
        "indirect": {
            "elm/json": "1.0.0"
        }
    },
    "test-dependencies": {
        "direct": {},
        "indirect": {}
    }
}

```

And I want to install `dillonkearns/elm-graphql` at version 4.2.1:

```auto
$ elm-json install dillonkearns/elm-graphql@4.2.1

-- NO VALID PACKAGE VERSIONS FOUND ---------------------------------------------

Because dillonkearns/elm-graphql 4.2.1 depends on elm/http 2.0.0 <= v < 3.0.0
and root depends on dillonkearns/elm-graphql 4.2.1, elm/http at versions other
than 2.0.0 <= v < 3.0.0 is incompatible with root.

And because root depends on elm/http 1.0.0, version solving failed.

```

Alright, so I need to upgrade my dependencies, and I should probably allow unsafe (~\> major) version bumps:

```sql
$ elm-json upgrade --unsafe

-- PACKAGE UPGRADES FOUND ------------------------------------------------------

I want to make some changes to your direct dependencies

- [CHG] elm/core 1.0.0 -> 1.0.2
- [CHG] elm/http 1.0.0 -> 2.0.0

I want to make some changes to your indirect dependencies

- [CHG] elm/json 1.0.0 -> 1.1.3
- [ADD] elm/bytes 1.0.8
- [ADD] elm/file 1.0.5
- [ADD] elm/time 1.0.0

Should I make these changes? [Y/n]

```

Cool, now let’s try that again:

```auto
$ elm-json install dillonkearns/elm-graphql@4.2.1

-- PACKAGE CHANGES READY -------------------------------------------------------

I want to make some changes to your direct dependencies

- [ADD] dillonkearns/elm-graphql 4.2.1

I want to make some changes to your indirect dependencies

- [ADD] Skinney/murmur3 2.0.8
- [ADD] elm-community/list-extra 8.2.0
- [ADD] elm/regex 1.0.0
- [ADD] elm/url 1.0.0
- [ADD] lukewestby/elm-string-interpolate 1.0.3

Should I make these changes? [Y/n]

```

There we go!

* * *

I’ll definitely make a post on discourse when I get around to actually releasing this. I realize third-party tools are never as nice, but at least it’s something, and it’s sooner rather than later.

_EDIT_: [This now exists](https://github.com/zwilias/elm-json)

---

<div class="post-metadata">

**Author:** ![berend](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/berend/32/2250_2.png) [@berend](https://discourse.elm-lang.org/u/berend)\
**Post date:** [April 21, 2019, 11:16pm UTC](https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528/3 "2019-04-21T23:16:50Z")

</div>

I suggest you have a look at [elm-upgrade](https://github.com/avh4/elm-upgrade) for the next upgrade.

---

<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:** [May 1, 2019, 11:16pm UTC](https://discourse.elm-lang.org/t/updating-dependencies-is-not-straightforward/3528/4 "2019-05-01T23:16:58Z")

</div>

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