1

We have a Phoenix application that has been running in production on Heroku for the last year.

Now I am attempting to enable pull request versions of the application to run via review apps as part of a Heroku pipeline.

The application has three Heroku buildpacks:

  1. https://buildpack-registry.s3.amazonaws.com/buildpacks/hashnuke/elixir.tgz
  2. https://github.com/gjaldon/heroku-buildpack-phoenix-static
  3. our own buildpack (see below)

Our own buildpack is very straightforward. Here is the bin/detect script:

#!/bin/sh

exit 0

And here is the bin/compile script:

#!/bin/bash

cd $1
mix release

Whilst the build has been working for production, unfortunately for the PR which is designed to enable review apps, it is failing when it gets to the final buildpack. Here is the relevant output from the Heroku build:

-----> https://github.com/orgname/buildpack-name.git app detected
** (ArgumentError) argument error
    :erlang.binary_to_atom(nil, :utf8)
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6
    (stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
    (stdlib) erl_eval.erl:236: :erl_eval.expr/5
    (stdlib) erl_eval.erl:228: :erl_eval.expr/5
    (stdlib) erl_eval.erl:878: :erl_eval.expr_list/6
    (stdlib) erl_eval.erl:404: :erl_eval.expr/5
 !     Push rejected, failed to compile https://github.com/orgname/buildpack-name.git app.
 !     Push failed

So it seems to be failing in the mix release step but the error message doesn't give me a good idea of why. I have found a similar problem report, which suggests that the problem I'm trying to solve may be due to one or more missing environment variables. However, I've double checked and can't see any environment variables that are missing.

Any suggestions about how I might solve this problem would be most welcome.

Keith Pitty
  • 1,498
  • 1
  • 12
  • 22
  • 1
    Just a clarification: are you aware of `mix release` does compile `config.exs`, but during release startup it loads **only** `releases.exs`? – Aleksei Matiushkin Aug 07 '20 at 07:49
  • @AlekseiMatiushkin thanks. Yes, I've been reviewing https://hexdocs.pm/mix/Mix.Tasks.Release.html as part of ensuring I understand the various aspects of this problem. What I'm currently trying to figure out is what's different about the review app environment compared with production with respect to releases. – Keith Pitty Aug 07 '20 at 08:27
  • In any case, that’s surely an unset environment variable issue. Try to print all of them out upon `Application.start/2` and see what’s missing? – Aleksei Matiushkin Aug 07 '20 at 15:05

1 Answers1

1

Thanks to Aleksei Matiushkin for his comments, which helped me track down the cause of the problem.

I had introduced a new environment variable, which I was fetching in both config/prod.exs and config/releases.exs. When I removed it from config/prod.exs then mix release succeeded in building the release for the Heroku review app.

I guess the moral of this story is to not configure a value both at build-time and runtime.

Keith Pitty
  • 1,498
  • 1
  • 12
  • 22