Elixir: mix test fails: could not find application file: decimal.app (with 1.7)

Created on 26 Jul 2018  路  14Comments  路  Source: elixir-lang/elixir

Environment

  • Elixir & Erlang/OTP versions (elixir --version):

    • Erlang/OTP 21 [erts-10.0.3]
    • Elixir 1.7.0 (compiled with Erlang/OTP 21)
  • Operating system:

    • macOS

Current behavior

I have a big umbrella project that fails with Elixir 1.7.0. When I cd into some of the umbrella apps and run the tests, I get the following error:

$ mix test
** (Mix) Could not start application decimal: could not find application file: decimal.app

Expected behavior

I think tests should run. They worked with v1.6.6.

Any thoughts?

Mix Bug

Most helpful comment

@josevalim It looks like I'm tuning in too late, and this has been already fixed. Thank you!

Also, thanks @chulkilee for helping get this fixed. I will try the fix on v1.7.2 when it gets released and if the problem persists I will supply a repo reproducing the error on my end.

All 14 comments

This was a bug in 1.7.0-rc.0 but fixed on 1.7.0. Are you sure you are on
1.7.0? What happens if you remove _build at the umbrella root?

If the problem persists, can you provide a smaller application that
reproduces the error? This can usually be done by reproducing the umbrella
structure with the mix.exs files but without all of the code in lib and

test.

Jos茅 Valim
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D

@josevalim Yep, I'm on 1.7. I've just installed it with brew.

I removed the _build directory before, but still failed. I removed it once again, and also updated a few deps and now it works. Weird!

Thank you!

I'm seeing this problem:

** (Mix) Could not start application decimal: could not find application file: decimal.app

Environment:

  • local machine

    • Mac OS X

    • Elixir 1.7.1-otp-21 (from asdf)

    • Erlang 21.0.4 (from asdf)

  • in docker

    • from alpine:3.8

    • Elixir 1.7.1 precompiled (from bob)

    • Erlang 21.0.4 (from official docker image)

I tried to make small repo to reproduce it, but failed reproduce reliably so far. I have a docker image which always raise this error, but I cannot share the image :(

What I'm seeing:

  • it's umbrella project

    • app A depends on jason => fail

    • app B depends on app A and jason => fail

    • app C depends on app A => fail

    • app D depends on app A, app B, app C => fail

    • app E depends on ecto => ok

  • _build/test/lib/app_a/ebin/app_a.app does not include decimal.
  • jason depends on decimal as optional
  • ecto requires decimal
  • if I add decimal as dependency to A, then all apps work

@chulkilee and I assume that if you remove _build then it goes back to working?

Not always :(

Also in docker case, it builds from scratch (with no _build).

FROM erlang:21.0.4-alpine

RUN set -xe \
    && apk add --no-cache curl unzip \
    && curl -fSL -o elixir-precompiled.zip https://repo.hex.pm/builds/elixir/v1.7.1-otp-21.zip \
    && echo "aa768d5e9ece02939f76be6a212c617500c1e84af23ba27fc1c10491ce7a2c5d  elixir-precompiled.zip" | sha256sum -c - \
    && unzip -d /usr/local elixir-precompiled.zip \
    && rm elixir-precompiled.zip \
    && apk del curl unzip \
    && mix local.hex --force \
    && mix local.rebar --force

ENV MIX_ENV=prod

RUN mkdir -p \
    apps/app_a \
    apps/app_b 

COPY mix.exs mix.lock ./
COPY apps/app_a/mix.exs apps/app_a/
COPY apps/app_b/mix.exs apps/app_b/

RUN mix deps.get && mix deps.compile && MIX_ENV=test mix deps.compile

COPY . .
RUN mix compile && MIX_ENV=test mix compile

CMD ["mix", "run", "--no-halt"]

And later, I run this image with MIX_ENV=test mix test, which runs this alias, not original mix test

  defp aliases do
    [
      test: ["cmd mix test"],
      test_only: ["cmd mix test --no-archives-check --no-compile --no-deps-check"]
    ]
  end

Are there any non-deterministic parts on dep resolution in umbrella app, when there is an optional dep?

Are there any non-deterministic parts on dep resolution in umbrella app, when there is an optional dep?

Well, it is not supposed to. :)

But the fact you can still reproduce it after a clean build is good news because it puts us closer to reproducing this. My suggestion is for you to pay attention to the order of the commands. For example, you compile at the root, then you test project a and you test project b, and that triggers it.

If you are up to it, we can also do a pairing session. Feel free to send me an e-mail (in my github profile).

I've been struggling with this bug again today with other apps besides decimal.

I don't know if this is helpful, but here are two scenarios I've discovered:

Scenario 1

$ cd umbrella
$ rm -rf ./_build
$ MIX_ENV=test mix compile
$ cd apps/app_1
$ mix test

** (Mix) Could not start application benchee: could not find application file: benchee.app

Note: benchee is not even listed in app_1/mix.exs as dependency. Benchee does however appear in other umbrella apps which app_1 has listed as dependencies.

Scenario 2

$ cd umbrella
$ rm -rf ./_build
$ cd apps/app_1
$ mix test

Finished in 0.02 seconds

This is all I've got for now!

@walkr we still need a way to reproduce this bug though. Maybe you can put your umbrella app in a new github repository? You can remove everything, we just need you to keep the mix.exs files.

@josevalim Here we go - I reproduced within Docker and local.

https://github.com/chulkilee/reproduce-elixir-7990

bash -c '
  rm -rf _build deps \
  && export MIX_ENV=prod \
  && mix deps.get && mix deps.compile && MIX_ENV=test mix deps.compile \
  && mix compile && MIX_ENV=test mix compile \
  && MIX_ENV=test mix cmd mix test
'

I am on it!

Here is a minimal failure step:

$ rm -rf _build deps
$ mix deps.get
$ mix test
$ mix cmd mix test

Closing in favor of #8035.

Thanks @chulkilee! The minimal repo was fundamental to get it fixed! :heart: :green_heart: :blue_heart: :yellow_heart: :purple_heart:

@josevalim It looks like I'm tuning in too late, and this has been already fixed. Thank you!

Also, thanks @chulkilee for helping get this fixed. I will try the fix on v1.7.2 when it gets released and if the problem persists I will supply a repo reproducing the error on my end.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Paddy3118 picture Paddy3118  路  3Comments

ericmj picture ericmj  路  3Comments

eproxus picture eproxus  路  3Comments

ckampfe picture ckampfe  路  3Comments

whitepaperclip picture whitepaperclip  路  3Comments