gcauchon
I’ve been working on many projects based on Phoenix in the last few years and worked on the transition from mix phx.server (for production environment) to OTP release with distillery then mix release. Starting last night, for a reason I can not explain, splitting mix deps.get and mix compile on different docker intermediate layers does not work anymore :
COPY mix.* ./
RUN mix deps.get --only ${MIX_ENV}
COPY . .
RUN mix compile
And fails with the following errors:
Unchecked dependencies for environment prod:
* parse_trans (Hex package)
lock mismatch: the dependency is out of date. To fetch locked version run "mix deps.get"
* mimerl (Hex package)
lock mismatch: the dependency is out of date. To fetch locked version run "mix deps.get"
…
* phoenix_ecto (Hex package)
lock mismatch: the dependency is out of date. To fetch locked version run "mix deps.get"
** (Mix) Can't continue due to errors on dependencies
The command '/bin/sh -c mix compile' returned a non-zero code: 1
Moving RUN mix deps.get after COPY . . works, but it defies the caching purposes of isolating dependencies… I tried on both MacOS and Ubuntu 18.04 with the same result ![]()
We have been using this setup for as long as I can remember for every ruby/node/elixir projects we are packaging as Docker images. Take a look at the elixir-boilerplate project we are maintaining to start every web projects at Mirego.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #elixirconf-eu
- #metaprogramming
- #hex











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
entone
There was an update to hex last night, there were some other errors prior to the update around parsing the old lock format. I saw similar errors to yours after the update, but a rerun resolved them.
I’m pretty sure it has to do with the docker caching, so you may need to break the cache.
sasajuric
+1 on cache clearing. Spent some time battling similar errors on CI. Removing the cache fixed the problem.
gcauchon
I had to
mix local.hexto updatehexlocally, thenmix deps.getto update the lock file to the “fixed” format, then my docker build started working again!For future references to anyone who might come across the same issue, here are the related issues:
shanesveller
If anyone is having Hex+Docker-related failures on CircleCI in particular, note that their layer caching is non-deterministic and can’t be intentionally cache-busted, so you’ll have to turn it off altogether for about a week:
https://circleci.com/docs/2.0/docker-layer-caching/#how-dlc-works
ericmj
This happens when you have a manifest file that is newer than your mix.lock file. That’s because you run
mix deps.getwhich updates your manifest and lock file but then your dockefile’sCOPYcommand introduces the old lockfile again. I would recommend against doingCOPY . .in your dockerfile, you should instead only copy what is needed for the next build step.I will publish a new release of Hex that mitigates this issue.
cnck1387
Which manifest file is this?
I haven’t deployed anything yet, but the lock file issue usually happens to me in development (because my volume mounted lock file has the old lock file). Running a
docker-compose run web mix deps.getfixes it and runs almost instantly. That gets the newly built lock file from the running container back to the Docker host.But I’m curious how that would happen in a CI or production environment because typically you wouldn’t be using a volume mount in those cases.
ericmj
It’s an internal manifest to Hex we write to
deps/$DEP/.hexwith information about the fetched dependency. We diff the information in the manifest file against the lockfile to determine if the the local dependency is outdated and needs to be fetched again to match the lock.In this case we marked the dependency as outdated because the manifest had a new field
:outer_checksumthat was missing in the lock.It happens when you do
COPY . .afterRUN mix deps.get, because it copies everything from the host to the container, includingmix.lockwhich is potentially outdated compared to the manifest in the container.gcauchon
I’m trying this as I type those lines!
gcauchon
Thanks for the detailed explanations AND for shipping
0.20.5already!Backward compatibility helps a lot as we don’t have to update all our active projects; but will do asap…
cnck1387
Oh, now I see why I never encountered this issue or heard of that file.
One of the first things I did in my app configuration was to set this in my
mix.iex:Now all of the dependencies are outside the scope of where you would
COPY . .and you don’t need to worry about all of your deps leaking back to your volume in development too.I do the same thing with Yarn too for
node_modules/.