elixir-lang / elixir

Elixir is a dynamic, functional language for building scalable and maintainable applications
https://elixir-lang.org/
Apache License 2.0
24.51k stars 3.38k forks source link

Missing dependency converged error for overridden hex dependency in umbrella #13490

Closed ericmj closed 7 months ago

ericmj commented 7 months ago

Elixir and Erlang/OTP versions

Erlang/OTP 26 [erts-14.2.2] [source] [64-bit] [smp:10:10] [ds:10:10:10] [async-threads:1] [jit]

Elixir 1.17.0-dev (100d63b) (compiled with Erlang/OTP 26)

mix hex.info: Hex: 2.0.7-dev Elixir: 1.17.0-dev OTP: 26.2.2

Built with: Elixir 1.17.0-dev and OTP 26.2.2

Operating system

macOS

Current behavior

This issue was originally reported here: https://github.com/hexpm/hex/issues/1010.

Given the dependency tree:

app_b (umbrella child)
  app_a (umbrella child)
    timex (hex)
      tzdata (hex)
  timex (hex)
    tzdata (hex)
  tzdata (git, override)
app_c (umbrella child)
  timex (hex)
    tzdata (hex)

The following error is raised:

* Updating tzdata (Hex package)
** (Mix) The lock is missing for package tzdata. This could be because another package has configured the application name for the dependency incorrectly. Verify with the maintainer of the parent application

Here is a repo that reproduces the error https://github.com/ericmj/umbrella_override_issue. Please use latest hex from the main branch as it has other fixes for umbrella apps.

Expected behavior

This error happens because hex does not add tzdata to the lock as it sees it as overridden, this may be incorrect behavior and should be investigated in hex. But in this case it should not matter since mix should detect that the dependencies are diverged since tzdata is not overridden all umbrella children.

ericmj commented 7 months ago

Another example of this issue can be found here https://github.com/hexpm/hex/issues/1019#issuecomment-2019136894 with another reproducing repo: https://github.com/khustochka/floki_test2_umbrella.

In this case mix does not detect the diverged {:floki, ">= 0.30.0", only: :test} from the umbrella child app and {:floki, "~> 0.36"} from phoenix_live_view. The error only happens when passing --only prod to mix deps.get.