HashNuke / heroku-buildpack-elixir

Heroku Buildpack for Elixir with nitro boost
MIT License
812 stars 311 forks source link

Unable to build app with Erlang 22.3 & Elixir 1.10.2 #172

Closed OldhamMade closed 4 years ago

OldhamMade commented 4 years ago

Buildpack config:

erlang_version=22.3
elixir_version=1.10.2
always_rebuild=true
release=true

Heroku console output:

-----> Elixir app detected
-----> Will export the following config vars:
DATABASE_URL
REDIS_URL
RELEASE_LEVEL
SECRET_KEY_BASE
       * MIX_ENV=prod
-----> Checking Erlang and Elixir versions
       Will use the following versions:
       * Stack heroku-18
       * Erlang 22.3
       * Elixir 1.10.2 
-----> Stack changed, will rebuild
-----> Cleaning all cache to force rebuilds
-----> Fetching Erlang 22.3 from https://s3.amazonaws.com/heroku-buildpack-elixir/erlang/cedar-14/OTP-22.3.tar.gz
-----> Installing Erlang 22.3 (changed)
-----> Fetching Elixir v1.10.2 for OTP 22 from https://repo.hex.pm/builds/elixir/v1.10.2-otp-22.zip
-----> Installing Elixir v1.10.2 (changed)
-----> Installing Hex
* creating /app/.mix/archives/hex-0.20.5
-----> Installing rebar
* creating /app/.mix/rebar
* creating /app/.mix/rebar3
-----> Fetching app dependencies with mix
** (FunctionClauseError) no function clause matching in IO.chardata_to_string/1    

    The following arguments were given to IO.chardata_to_string/1:

        # 1
        nil

    Attempted function clauses (showing 2 out of 2):

        def chardata_to_string(+string+) when -is_binary(string)-
        def chardata_to_string(+list+) when -is_list(list)-

    (elixir 1.10.2) lib/io.ex:572: IO.chardata_to_string/1
    (elixir 1.10.2) lib/path.ex:520: Path.join/2
    (stdlib 3.12) erl_eval.erl:680: :erl_eval.do_apply/6
    (stdlib 3.12) erl_eval.erl:786: :erl_eval.eval_map_fields/5
    (stdlib 3.12) erl_eval.erl:263: :erl_eval.expr/5
    (stdlib 3.12) erl_eval.erl:232: :erl_eval.expr/5
    (stdlib 3.12) erl_eval.erl:888: :erl_eval.expr_list/6
    (stdlib 3.12) erl_eval.erl:240: :erl_eval.expr/5
 !     Push rejected, failed to compile Elixir app.
 !     Push failed

Running mix deps.get --only prod locally (macOS) no issues.

OldhamMade commented 4 years ago

Also tried a few variations, including OTP 21.3.7 with Elixir 1.9.4 – still no joy.

jesseshieh commented 4 years ago

Have you tried clearing out your build cache? I've never seen that error before. Is this on Heroku or Gigalixir?

OldhamMade commented 4 years ago

@jesseshieh thanks for the response!

It's on Heroku. I forgot to mention before: this is part of a pipeline and is the output from the automated Review app build process. Whenever the PR is updated a new review app is created and seems to get a unique name each time. As I understand it, this should mean that there's no cache to be cleared.

For the sake of completeness, I did the following:

$ heroku plugins:install heroku-repo
$ heroku repo:purge_cache -a $MYAPP

Set always_rebuild=true, pushed, but got same error in my review app output.

OldhamMade commented 4 years ago

Found the issue:

My Review app environment had a missing environment variable, one which was required by one of the libraries I use as a dependency. Because the environment variable was not set, the dep saw it as nil, and then failed to compile since it was expecting a string.

Simply setting the environment variable correctly allowed the app to build as expected. It's unfortunate that the error didn't really provide any further details as to where the issue was.

I'm going to close this ticket, but I hope that this helps others in a similar position. Always remember the golden rule of debugging: always, always, triple-check your assumptions!

jesseshieh commented 4 years ago

@OldhamMade That's great! Thanks for reporting back.