tmariaz

tmariaz

Unable to deploy phoenix with edeliver which throws an compile_env/4 error

I am trying to deploy the app with edeliver. However during the … I get the following error. Not sure what is it actually means. Though in the dev environment it works fine.

  1. mix compile - Successful
  2. iex -S mix phx.server - I can serve the api and no issues.
  3. Guardian can also authenticate the JWT token

So puzzled about deployment.

Building the code for edeliver

mix edeliver build release --verbose

Error:

Changed release version from 0.2.1 to 0.2.1+3-59fa8ac
Compiling 284 files (.ex)

== Compilation error in file lib/pxrf/auth/guardian.ex ==
** (FunctionClauseError) no function clause matching in Application."MACRO-compile_env"/4    
    
    The following arguments were given to Application."MACRO-compile_env"/4:
    
        # 1
        #Macro.Env<aliases: [], context: nil, context_modules: [Pxrf.Auth.Guardian], file: "/tmp/edeliver/pxrf/builds/lib/pxrf/auth/guardian.ex", function: nil, functions: [{Kernel, [!=: 2, !==: 2, *: 2, +: 1, +: 2, ++: 2, -: 1, -: 2, --: 2, /: 2, <: 2, <=: 2, ==: 2, ===: 2, =~: 2, >: 2, >=: 2, abs: 1, apply: 2, apply: 3, binary_part: 3, bit_size: 1, byte_size: 1, ceil: 1, div: 2, elem: 2, exit: 1, floor: 1, function_exported?: 3, get_and_update_in: 3, get_in: 2, hd: 1, inspect: 1, inspect: 2, is_atom: 1, is_binary: 1, is_bitstring: 1, is_boolean: 1, is_float: 1, is_function: 1, is_function: 2, ...]}], lexical_tracker: #PID<0.644.0>, line: 2, macro_aliases: [], macros: [{Kernel, [!: 1, &&: 2, ..: 2, ..//: 3, <>: 2, @: 1, alias!: 1, and: 2, binding: 0, binding: 1, def: 1, def: 2, defdelegate: 2, defexception: 1, defguard: 1, defguardp: 1, defimpl: 2, defimpl: 3, defmacro: 1, defmacro: 2, defmacrop: 1, defmacrop: 2, defmodule: 2, defoverridable: 1, defp: 1, defp: 2, defprotocol: 2, defstruct: 1, destructure: 2, get_and_update_in: 2, if: 2, in: 2, is_exception: 1, is_exception: 2, is_nil: 1, is_struct: 1, is_struct: 2, ...]}], module: Pxrf.Auth.Guardian, requires: [Application, Guardian, Kernel, Kernel.Typespec], ...>
    
        # 2
        {:the_otp_app, [line: 2, counter: {Pxrf.Auth.Guardian, 2}], Guardian}
    
        # 3
        [{:__MODULE__, [line: 2, counter: {Pxrf.Auth.Guardian, 2}], Guardian}, :permissions]
    
        # 4
        nil
    
    (elixir 1.12.2) lib/application.ex:505: Application."MACRO-compile_env"/4
    (elixir 1.12.2) expanding macro: Application.compile_env/2
    lib/pxrf/auth/guardian.ex:2: Pxrf.Auth.Guardian (module)
    (elixir 1.12.2) expanding macro: Kernel.||/2
    lib/pxrf/auth/guardian.ex:2: Pxrf.Auth.Guardian (module)
    (elixir 1.12.2) expanding macro: Kernel.@/1
    lib/pxrf/auth/guardian.ex:2: Pxrf.Auth.Guardian (module)
    (guardian 2.3.1) expanding macro: Guardian.__using__/1

A remote command failed on:

    user@server

  Output of the command is shown above and the command executed
  on that host is printed below for debugging purposes:

  FAILED with exit status 1:

    [ -f /Users/username/.profile ] && source /Users/username/.profile
    set -e
    cd /tmp/edeliver/pxrf/builds
    if [ "mix" = "rebar3" ]; then
      echo "using rebar3 to compile files"
      [[ "true" != "true" ]] && ./rebar3  clean || :
      ./rebar3  compile
    elif [ "mix" = "rebar" ]; then
      echo "using rebar to compile files"
      [[ "true" != "true" ]] && ./rebar  clean skip_deps=true || :
      ./rebar  compile
    elif [ "mix" = "mix" ] && [ "mix" = "mix" ]; then
      echo "Checking whether deps must be compiled for mix version 1.3.[01234]"
      # see https://github.com/boldpoker/edeliver/issues/94
      if mix --version | grep 'Mix 1.3.[01234]' >/dev/null 2>&1 ; then
        echo "Compiling deps because mix version 1.3.[01234] is used"
        APP="pxrf" MIX_ENV="prod" mix deps.compile
      fi
      if [[ "true" = "true" ]]; then
        APP="pxrf" MIX_ENV="prod" AUTO_VERSION="commit-count+git-revision+branch-unless-master" BRANCH="master" SKIP_RELUP_MODIFICATIONS="" RELUP_MODIFICATION_MODULE="" USING_DISTILLERY="true" mix do release.version  --verbose, compile
      else
        APP="pxrf" MIX_ENV="prod" AUTO_VERSION="commit-count+git-revision+branch-unless-master" BRANCH="master" SKIP_RELUP_MODIFICATIONS="" RELUP_MODIFICATION_MODULE="" USING_DISTILLERY="true" mix do clean, release.version  --verbose, compile
      fi
    elif [ "mix" = "mix" ]; then
      echo "using mix to compile files"
      if [[ "true" = "true" ]]; then
        if [[ -n "commit-count+git-revision+branch-unless-master" ]]; then
          hint_message 'Using --auto-version together with --skip-mix-clean would not work!'
        fi
        APP="pxrf" MIX_ENV="prod" AUTO_VERSION="commit-count+git-revision+branch-unless-master" BRANCH="master" SKIP_RELUP_MODIFICATIONS="" RELUP_MODIFICATION_MODULE="" USING_DISTILLERY="true" mix do deps.compile, release.version  --verbose, compile
      else
        APP="pxrf" MIX_ENV="prod" AUTO_VERSION="commit-count+git-revision+branch-unless-master" BRANCH="master" SKIP_RELUP_MODIFICATIONS="" RELUP_MODIFICATION_MODULE="" USING_DISTILLERY="true" mix do clean, deps.compile, release.version  --verbose, compile
      fi
    fi

Most Liked

al2o3cr

al2o3cr

Can you show the first few lines of this module? The error message suggests there’s something weird being passed to Application.compile_env there.

al2o3cr

al2o3cr

Here’s the part of Guardian.__using__/1 that’s failing to compile:

The underlying issue is the Elixir version - 1.12 has a bug where using a local variable (or module attribute) as the first argument to Application.compile_env/3 produces exactly the error message you’re seeing:

High-five to @eksperimental for this fix!

I’m still not sure why this only happens when running edeliver, though; is it possible it’s picking up the wrong version of the compiler?

al2o3cr

al2o3cr

To clarify: the bug I highlighted was unrelated to edeliver, it means that you can’t use Elixir 1.12 together with Guardian 2.3.1.

The connection to edeliver was that it appears that only edeliver was trying to use this combination; mix compile and mix phx.server weren’t seeing the error.


Can you post the application section of your mix.exs? The edeliver readme suggests adding to applications: which is no longer recommended (use extra_applications instead, or rely on Mix auto-detection), and that can cause weird behavior.

Where Next?

Popular in Questions Top

pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sacepums
Hey guys. I'm new to elixir and im really stocked about it. But I ran into a bit of problem - I need to convert a date sting, for examp...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
mathew4509
I have a list say x = ["23gh", "56kh", "97mh"] I would like to pass each element to Val in each iteration. Say, in iteration 1 -------...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Other popular topics Top

sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 49522 488
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

We're in Beta

About us Mission Statement