Updating dependencies is not straightforward

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

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:

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/ linked from here:
Dependencies analyzer for application elm.json - #9 by jxxcarlson

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

8 Likes

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:

{
    "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:

$ 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:

$ 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:

$ 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

13 Likes

I suggest you have a look at elm-upgrade for the next upgrade.

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