How do I update dependancy of dependancy?

On my project:

$ mix hex.outdated --all      
Dependency           Current  Latest  Status
[...]
plug_cowboy          2.3.0    2.5.1   Update possible      
[...]

OK, so plug_cowboy is out of date. I think this might be why my application is crashing in fact (see Fix compatibility with ranch 2.x by asabil · Pull Request #64 · elixir-plug/plug_cowboy · GitHub). Apparently updating this is possible.

But I can’t get it to update.

Have tried:

$ mix deps.update --all
$ mix deps.update plug_cowboy

But plug_cowboy is listed as “unchanged” and still the old version.

How do I update this?

Maybe you are limiting the mayor version to update. Check this link: Version — Elixir v1.12.3

Hope this clarifies it.

Yes, noticed that the dependency locked it to “~> 2.0”.

But why does it say “update possible”?

Oh well, I think I have solved this at least.

Also not sure I understand how “~> 2.0” allows version 2.3, but not 2.5.

I think this would be worth filing a bug if you can.

What package should I file the bug against?

Sometimes I find I have to mix deps.unlock <package name> before I run mix deps.update <package_name>. I do think there are some hex resolver issues (which I know the team is working on) which might be a contributor to the situation.

5 Likes

Thanks for the bug report reference. Looks like it might be the problem I encountered.

Something that’s worth mentioning in these kinds of threads:

mix deps.clean --unlock --unused

Which removes all unused dependencies from your mix.lock file and deps directory. I feel this has to be automatically invoked after most mix deps.* commands but I am probably missing something very important because it hasn’t happened yet.