Mix deps.update working as mix deps.downgrade

defp deps do
    [
      {:amqp, "~> 1.3.2"}
    ]
  end

mix deps.update --all
results in:

Unchanged:
  amqp 1.3.2

{:amqp, "~> 1.3.1"}
results in:

Downgraded:
  amqp 1.3.2 => 1.3.1

{:amqp, ">= 1.3.0"}
results in:

Downgraded:
  amqp 1.3.1 => 1.3.0

{:amqp, ">= 0.0.0"}
result in:

Downgraded:
  amqp 1.3.0 => 0.3.0

Am I missing something or deps.update should be renamed to deps.downgrade?

1 Like

Update here means β€˜update my installed package versions to match my configuration requirements’. Since in each of your cases you were adjusting your requirement to a lower version, mix complied with your request and noted that in order to comply it had to downgrade your package,

Short version: update != upgrade.

2 Likes

But each of those version specs should have matched 1.3.2, no? (If it was the newest version.)

2 Likes

With the exception of ~> 1.3.1, I would have thought so.

https://hexdocs.pm/mix/master/Mix.Tasks.Deps.Update.html

The given dependencies and the projects they depend on will be unlocked and updated to the latest version according to their version requirements.

So the documentation says something other.

Any of those examples should install 1.3.2, because it’s the latest version meeting my requirements.

1 Like

believe this is a specific issue with the amqp package - see https://github.com/pma/amqp/pull/161 and other issues/commits in that repo…

try with ranch {:ranch, β€œ>= 0.0.0”} and 1.7.0, 1.7.2 etc and you get expected results

1 Like

It definitely downgrades. I get the same issue with jason:

$ mix deps.update jason
Upgraded:
  jason 1.0.0 => 1.2.2
$ mix deps.update --all
Downgraded:
  jason 1.2.2 => 1.0.0

Here is the mix deps.tree with only jason-relevant output:

β”œβ”€β”€ jason ~> 1.0 (Hex package)
β”œβ”€β”€ postgrex >= 0.0.0 (Hex package)
β”‚   └── jason ~> 1.0 (Hex package)
β”œβ”€β”€ ecto_sql ~> 3.0 (Hex package)
β”‚   β”œβ”€β”€ ecto ~> 3.1.0 (Hex package)
β”‚   β”‚   └── jason ~> 1.0 (Hex package)
β”œβ”€β”€ phoenix ~> 1.4.0 (Hex package)
β”‚   β”œβ”€β”€ jason ~> 1.0 (Hex package)

It must be a bug.

$ mix --version
Erlang/OTP 23 [erts-11.0.4] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Mix 1.10.4 (compiled with Erlang/OTP 23)

Can you share your mix.exs and mix.lock files so that we can try to reproduce and investigate? If it’s an umbrella project please share all mix.exs files.

Sure thing. I could reproduce it with those 3 packages:

  defp deps do
    [
      {:jason, "~> 1.0"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_params, "~> 1.1"}
    ]
  end

With those in place, mix deps.update --all resolves jason to 1.0.0
With any of postgrex, phoenix_params missing, it resolves jason to 1.2.2

Here is the mix.exs:

defmodule Deptest.MixProject do
  use Mix.Project

  def project do
    [
      app: :deptest,
      version: "0.1.0",
      elixir: "~> 1.10",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  def application do
    [
      extra_applications: [:logger]
    ]
  end

  defp deps do
    [
      {:jason, "~> 1.0"},
      {:postgrex, ">= 0.0.0"},
      {:phoenix_params, "~> 1.1"}
    ]
  end
end

Here is the mix.lock:

%{
  "decimal": {:hex, :decimal, "1.9.0", "83e8daf59631d632b171faabafb4a9f4242c514b0a06ba3df493951c08f64d07", [:mix], [], "hexpm", "b1f2343568eed6928f3e751cf2dffde95bfaa19dd95d09e8a9ea92ccfd6f7d85"},
  "jason": {:hex, :jason, "1.0.0", "0f7cfa9bdb23fed721ec05419bcee2b2c21a77e926bce0deda029b5adc716fe2", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "b96c400e04b7b765c0854c05a4966323e90c0d11fee0483b1567cda079abb205"},
  "mime": {:hex, :mime, "1.4.0", "5066f14944b470286146047d2f73518cf5cca82f8e4815cf35d196b58cf07c47", [:mix], [], "hexpm", "75fa42c4228ea9a23f70f123c74ba7cece6a03b1fd474fe13f6a7a85c6ea4ff6"},
  "phoenix": {:hex, :phoenix, "1.5.4", "0fca9ce7e960f9498d6315e41fcd0c80bfa6fbeb5fa3255b830c67fdfb7e703f", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_html, "~> 2.13", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.0", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:plug, "~> 1.10", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 1.0 or ~> 2.2", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.1.2 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "4e516d131fde87b568abd62e1b14aa07ba7d5edfd230bab4e25cc9dedbb39135"},
  "phoenix_params": {:hex, :phoenix_params, "1.1.1", "9ded854159604505ad8d101bf25f058b4c0ac20778b8d20dd6f09da0c7d73509", [:mix], [{:decimal, ">= 1.7.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:phoenix, ">= 1.3.3", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "59c1d96d92899083fbc2e87be34447133a81e72e14c46f85d999cc3de5a3880d"},
  "phoenix_pubsub": {:hex, :phoenix_pubsub, "2.0.0", "a1ae76717bb168cdeb10ec9d92d1480fec99e3080f011402c0a2d68d47395ffb", [:mix], [], "hexpm", "c52d948c4f261577b9c6fa804be91884b381a7f8f18450c5045975435350f771"},
  "plug": {:hex, :plug, "1.10.4", "41eba7d1a2d671faaf531fa867645bd5a3dce0957d8e2a3f398ccff7d2ef017f", [:mix], [{:mime, "~> 1.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ad1e233fe73d2eec56616568d260777b67f53148a999dc2d048f4eb9778fe4a0"},
  "plug_crypto": {:hex, :plug_crypto, "1.1.2", "bdd187572cc26dbd95b87136290425f2b580a116d3fb1f564216918c9730d227", [:mix], [], "hexpm", "6b8b608f895b6ffcfad49c37c7883e8df98ae19c6a28113b02aa1e9c5b22d6b5"},
  "postgrex": {:hex, :postgrex, "0.7.0", "93b33b086bcbef25ff57c6231de68ac89c3b8a2a84a700ccd3101cebf4c12993", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: false]}], "hexpm", "dbc670892f17458b2dcef1b346ad2e70fea43fdc7e29e4b6c0f31b023cc272d5"},
  "telemetry": {:hex, :telemetry, "0.4.2", "2808c992455e08d6177322f14d3bdb6b625fbcfd233a73505870d8738a2f4599", [:rebar3], [], "hexpm", "2d1419bd9dda6a206d7b5852179511722e2b18812310d304620c7bd92a13fcef"},
}
2 Likes

I have observed a similar (or same) issue with one of my libs. I was sure I submitted an issue but now I can’t find it.

I found that if I manually unlocked the dependency that wasn’t being resolved correctly then mix would correctly resolve it. It was also a dependency that was defined both in the current project and also defined as a transitive dependency (but both with the same version string). I do not know if the issue was correlated with both of these elements or just the first one.

I will go back and reproduce and submit an issue. Very puzzled why I can’t find it now.

1 Like

Reproduced it does not pick up the latest jason version (1.2.2)

mix deps.get && mix deps.tree
Resolving Hex dependencies...
Dependency resolution completed:
New:
  decimal 1.9.0
  jason 1.0.0
  mime 1.4.0
  phoenix 1.5.4
  phoenix_params 1.1.1
  phoenix_pubsub 2.0.0
  plug 1.10.4
  plug_crypto 1.1.2
  postgrex 0.7.0
  telemetry 0.4.2
* Getting jason (Hex package)
* Getting postgrex (Hex package)
* Getting phoenix_params (Hex package)
* Getting decimal (Hex package)
* Getting phoenix (Hex package)
* Getting phoenix_pubsub (Hex package)
* Getting plug (Hex package)
* Getting plug_crypto (Hex package)
* Getting telemetry (Hex package)
* Getting mime (Hex package)
deptest
β”œβ”€β”€ jason ~> 1.0 (Hex package)
β”‚   └── decimal ~> 1.0 (Hex package)
β”œβ”€β”€ postgrex >= 0.0.0 (Hex package)
β”‚   └── decimal ~> 1.0 (Hex package)
└── phoenix_params ~> 1.1 (Hex package)
    β”œβ”€β”€ decimal >= 1.7.0 (Hex package)
    └── phoenix >= 1.3.3 (Hex package)
        β”œβ”€β”€ jason ~> 1.0 (Hex package)
        β”œβ”€β”€ phoenix_pubsub ~> 2.0 (Hex package)
        β”œβ”€β”€ plug ~> 1.10 (Hex package)
        β”‚   β”œβ”€β”€ mime ~> 1.0 (Hex package)
        β”‚   β”œβ”€β”€ plug_crypto ~> 1.1.1 or ~> 1.2 (Hex package)
        β”‚   └── telemetry ~> 0.4 (Hex package)
        β”œβ”€β”€ plug_crypto ~> 1.1.2 or ~> 1.2 (Hex package)
        └── telemetry ~> 0.4 (Hex package)

It is interesting that hex.outdated shows it’s upgradable!

mix hex.outdated --all
Dependency      Current  Latest  Update possible
decimal         1.9.0    2.0.0   No
jason           1.0.0    1.2.2   Yes
mime            1.4.0    1.4.0
phoenix         1.5.4    1.5.4
phoenix_params  1.1.1    1.1.2   Yes
phoenix_pubsub  2.0.0    2.0.0
plug            1.10.4   1.10.4
plug_crypto     1.1.2    1.1.2
postgrex        0.7.0    0.15.5  Yes
telemetry       0.4.2    0.4.2

Updating with mix deps.update --all does not update jason.

mix deps.update --all

Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  decimal 1.9.0
  jason 1.0.0
  mime 1.4.0
  phoenix 1.5.4
  phoenix_params 1.1.1
  phoenix_pubsub 2.0.0
  plug 1.10.4
  plug_crypto 1.1.2
  postgrex 0.7.0
  telemetry 0.4.2

However, I could update jason with unlocking and then updating it.

mix deps.unlock jason && mix deps.update jason
Resolving Hex dependencies...
Dependency resolution completed:
Unchanged:
  decimal 1.9.0
  mime 1.4.0
  phoenix 1.5.4
  phoenix_params 1.1.1
  phoenix_pubsub 2.0.0
  plug 1.10.4
  plug_crypto 1.1.2
  postgrex 0.7.0
  telemetry 0.4.2
New:
  jason 1.2.2
* Updating jason (Hex package)

Tested at

elixir --version
Erlang/OTP 23 [erts-11.0.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Elixir 1.10.4 (compiled with Erlang/OTP 23)

mix --version
Erlang/OTP 23 [erts-11.0.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]

Mix 1.10.4 (compiled with Erlang/OTP 23)
1 Like

Bingo, exactly my experience. And almost exactly the same as the issue I logged (well, was sure I logged but I can’t find it).

Thanks for the instructions on how to reproduce.

I have found the issue and created a PR: https://github.com/hexpm/hex/pull/810.

8 Likes