When i try to execute mix.deps.get after removing mix.lock, the terminal hangs at Resolving Hex dependencies... . The process then starts to eat all available memory and swap …
my-app|qa⚡ ⇒ mix hex.info
Hex: 0.20.5
Elixir: 1.9.4
OTP: 22.1.4
Built with: Elixir 1.9.4 and OTP 22.1.4
Those issues are caused by the dependency resolution algorithm. It means the search space is too big and finding suitable solutions takes too long. The simplest suggestion to address this is to constraint your dependencies. For example, if you have Ecto ~> 3.0, update to latest Ecto ~> 3.6 and so on.
If you have a lock file, then update your deps in groups, doing mix deps.update phoenix ecto instead of passing the --all flag.
We have some possible improvements in mind for dependency resolution but, if the search space is too big, ultimately there won’t be much we can do.
A key point I learned from this thread is that if you have a mix.lock file already, then this dependency resolution isn’t necessary, so you won’t run out of memory.
So if you’re having this problem on your server, try running on your development machine and committing the mix.lock.
(I came across this thread while trying out deploying a phoenix app on a tiny free google cloud server, and my first thought was to just run phx.new and fire it up, which didn’t work because it didn’t have the memory to run mix deps.get)
We are working on a fix to this issue but it requires a full rewrite of the resolver algorithm so unfortunately it will take some time until it is released and in production quality.
In the mean time make sure you always commit your mix.lock file and follow the instructions here if you run into issues.
sure, we always commit it.
but sometimes, if you have dependencies version conflict - you need to remove the .lock file …
in my case - when i had to remove the lock file - i got this issue in my local mac (not in dock/any deployment env) - so @josevalim answer solved it for me, (updating the Ecto version was enough)
You don’t have to remove the mix.lock when you have conflicts. Mix won’t write a lockfile if the resolution has conflicts. Instead unlock or update the individual deps that are conflicting.
Hey,
I am experiencing the same problem, on the deployment docker file even when I run it locally.
I identified that id I comment out these 3 deps, then we are ok, but the 3 together causes the problem.
I have a mix.lock
I am wondering that the docker file that I inherited might causes this partially because locally I can get the deps without any issues, only I am trying to build the container I am getting the problem.
I hadn’t come across your answer, but from the earlier posts I realized a similar thing. If the mix.lock file is gone, it will throw that error it seems. Simply comment out all but one dependency. Run a deps.get, then you can likely uncomment all the rest (I uncommented in groups of about 5 or so). I’d guess that having at least one in a lock file is the key to circumventing this search space issue.