hexpm / hex

Package manager for the Erlang ecosystem.
https://hex.pm
972 stars 184 forks source link

Infinite loop encountered in requirement solver #961

Closed benjamin-brewer closed 1 year ago

benjamin-brewer commented 1 year ago

I'm still trying to dig up an actual mix.exs and mix.lock that will reproduce this, as it's happening in a private repo for me.

Basically, I'm running into an infinite loop for a dependency (jason) when I hit this function https://github.com/hexpm/hex/blob/cf5b231dc83654d4eeb1f7c8ab71a08053d3bbe2/lib/hex/solver/requirement.ex#L101 with (:~>, {1, 3, nil, [], []}, :~>, {1, 2, nil, [], []}). As in the function just calls itself over and over again when the first and third args are the same.

Like I said, I'll try and come up with an example repo with a lock file that can force this to happen. Thanks!

Other details:

benjamin-brewer commented 1 year ago

Here is a repo and mix file with an example of the problem. I narrowed it down to a private repo that has a dep spec that is {:jason, "~> 1.2 and ~> 1.3"}, which I honestly haven't read the docs enough to know if that's even legimate anymore/ever 😅 . We also found locations that were using or, so those may be a bit more practical? Ex. {:telemetry, "~> 0.4 or ~> 1.0"}

We'll fix those particular specs, but would it be possible to have a nice error message instead of an infinite loop, in this case?

https://github.com/benjamin-brewer/hex_loop_example/blob/main/mix.exs

ericmj commented 1 year ago

Thanks for the report. This fix will be included in the next release.