Phoenix no longer deploying - mix deps.get error (undefined function: Mix.State.get/2)

Hello everyone! So my builds suddenly stopped working, but I’m not sure why. It fails during mix deps.get in the dockerfile (which I find really odd). Here is the error message that I receive and here is the exact commit which caused it to fail.

* Getting phoenix (Hex package)
** (UndefinedFunctionError) undefined function: Mix.State.get/2 (module Mix.State is not available)
    Mix.State.get(:debug, false)
    (hex) lib/hex/shell.ex:22: Hex.Shell.debug/1
    (hex) lib/hex/scm.ex:125: Hex.SCM.update/1
    (hex) lib/hex/scm.ex:196: Hex.SCM.checkout/1
    (mix) lib/mix/dep/fetcher.ex:64: Mix.Dep.Fetcher.do_fetch/3
    (mix) lib/mix/dep/converger.ex:154: Mix.Dep.Converger.all/8
    (mix) lib/mix/dep/converger.ex:47: Mix.Dep.Converger.converge/4
    (mix) lib/mix/dep/fetcher.ex:16: Mix.Dep.Fetcher.all/3
The command "mix deps.get" failed and exited with 1 during .

I’m thinking it could be a number of potential things.

  • I removed the entire .elixir_ls folder from git (I read online that this is fine)
  • I used the Timex library inside of the xxx_web - view function. But that seems odd

What’s weird is that everything works 100% fine on local, it’s just failing during this step and I can’t find any information as to why.

Aside from that, I really can’t figure out why. Any help is greatly appreciated.

I don’t actually think it has anything to do with my code, and there might actually be a bug in the phoenix framework package? I’ve tried reverting the commit and I still get the same message, so I’m not sure. This is what my Dockerfile is, and I can’t imagine how my code is even involved at this point when mix deps.get is run.

FROM elixir:1.8.2-alpine as build

ENV MIX_ENV=prod

ENV PORT=4000

ARG AWS_ACCESS_KEY

ARG AWS_SECRET_KEY

ARG JSON_API

ARG HOST

ARG POSTGRES_USER

ARG POSTGRES_PASSWORD

ARG POSTGRES_DB

ARG POSTGRES_HOST

ARG SECRET_KEY_BASE

WORKDIR /app

COPY . .

RUN apk update && \

apk add -u musl musl-dev musl-utils nodejs-npm build-base python2

RUN mix local.hex --force \

&& mix local.rebar --force \

&& mix hex.info

RUN mix deps.get --only prod

Do you have _build in your .dockerignore file?

I think you need to avoid copying your _build directory into the docker container, so that it does the entire build there.

Something else you might try is deleting all your existing images/layers and rebuilding.

Yes, it seems to be there:

The dockerfile builds well for me…

Please make sure you are building from a fresh docker cache to make sure that there is nothing wrog in a cached layer.

Thanks for all your responses, I really appreciate it. I believe I already am building with a fresh docker cache as per the .travis.yml file with the --no-cache directive.

How would deleting the existing images help on the server jeremyjh, if the image is being built on travis? Like, how would I go about that, and isn’t that what --no-cache is doing anyway?

- docker-compose build --build-arg AWS_ACCESS_KEY="$AWS_ACCESS_KEY" --build-arg AWS_SECRET_KEY="$AWS_SECRET_KEY"
  --build-arg JSON_API="$JSON_API" --build-arg HOST="$HOST" --build-arg POSTGRES_USER="$POSTGRES_USER"
  --build-arg POSTGRES_PASSWORD="$POSTGRES_PASSWORD" --build-arg POSTGRES_DB="$POSTGRES_DB"
  --build-arg POSTGRES_HOST="$POSTGRES_HOST" --build-arg SECRET_KEY_BASE="$SECRET_KEY_BASE"
  --no-cache nfd-app

Wait, I’m just skimming through your travis logs, but Elixir 1.0.2? Is that correct? Is this really the version you want to run?

Because thats the big difference in the logs I see between the succesful build #206 and the first failing #207. Funnily enough, the travis.yml that I can see in the #207 commit is not different from that in the #206 commit.

Even worse… The log of #207 does not really match any travis.yml I coudld find…

2 Likes

Excellent. I’ve figured it out. Thank you so much for your help.

So I’ve done nothing wrong on my end (well, yes and no) but essentially I think travis CI might have actually changed something on their end in terms of how they interpret the .travis.yml file.

Initially I only specified the language, however I’ve now specified the version and everything is building again :slight_smile:

Here’s what the travis file looks like now!

language: elixir
elixir:
  - '1.8.2'
otp_release:
  - '22.0'
2 Likes