How do your upgrade a package in your app

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 author/package

Elm responds with It is already installed! without upgrading the version.

Doing:

elm install author/package@x.y.z

Doesn’t work.

Changing the version manually works fine if there are no dependecy conflicts. So this is to be only a problem when deps don’t match.

I had to manually find the conflicting packages in indirect in elm.json an change the version.

Is there a better workflow for this?

14 Likes

I usually just remove the direct dependency from elm.json then do elm install author/package again to let Elm generate dependencies.

4 Likes

That doesn’t work. I just tried that to upgrade from elm/http 1.0.0 to 2.0.0, but elm install elm/http is still installing 1.0.0 after I removed elm/http from elm.json.

Try removing elm-stuff too.

Elm/JSON was bumped on the same day, and Elm/HTTP relies on Elm/JSON. Bump both and it should start working. (Elm/core was bumped 5 days ago too, and I think Elm/HTTP requires the new one, so depending on your project’s age you might want to change Elm/core’s version as well.)

ok, I had to remove all three to get elm/http 2.0.0.

I find it strange that there is no warning when I run elm install elm/http about installer being unable to install newest version because of dependency conflicts.

Its just not a mature tool yet.

The dependencies in your elm.json are not compatible.

But which ones? Elm errors are famously helpful, but not this one.

Can the community help out here? Would it at least be productive to have a discussion on what features elm init needs to support to be usable?

elm install does not install the latest version, it installs the latest version compatible with your other dependencies. If you have other dependencies requiring elm/http "1.0.0 <= v < 2.0.0", elm install won’t be able to install elm/http 2.0.0. If no version is compatible, it will complain.

As far as I know, the behavior is similar to other semver installers, like npm (there is no warning either when it cannot install the latest version).

I don’t think this is needed.

1 Like

Has anyone built a tool that will find conflicting versions?

I’m trying to upgrade http to 2.0, and would like to avoid having to inspect all the ‘elm.json’ for all the packages we use (and the deps of those packages).

2 Likes

Another odd thing I found the other day is this error message pointing to elm reactor for dependency changing and stuff. https://github.com/elm/compiler/blob/a6568a63f3ffc4defdb608d180b23a0113a89342/builder/src/Reporting/Exit/Deps.hs#L104-L108

I don’t think it’s possible right now, is it?

I’d guess adding a patch to the compiler is probably the best solution, even if wouldn’t get merged. https://github.com/elm/compiler/issues/1831#issuecomment-439930671

We’re having trouble updating to http 2.0.0 as well… We’ll try using the tips in this thread, but surely the package manager should be more helpful =)

I’ve managed to update elm/http by updating my elm binary. Don’t know if this is a correlation or a causation though

The way I did it was to rm elm.json && elm init, then repeat this process:

elm make
#fix compilation errors from http 2.0.0 if you've arrived at that point
elm install <the thing make fails on>

This way, when I came to elm install elm/http, there was nothing in elm.json that would prevent it from choosing the newest version.

This process does imply that you’re updating all your dependencies to the latest version, not just one particular dependency. But one could imagine a slightly more complex variation on it that would focus on a single upgrade, something like:

elm make
#if you're at or beyond the point of errors about http then:
    #fix compilation errors from http 2.0.0 if you've arrived at that point
    elm install <the thing make fails on>
#else
    #manually restore the line in elm.json that make failed on
1 Like

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