Elixir: ** (ArgumentError) argument error on every invocation of Mix

Created on 27 Nov 2018  路  6Comments  路  Source: elixir-lang/elixir

This only happens within my project tree, but I don't know how to troubleshoot it. The error is not very informative.

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
Erlang/OTP 21 [erts-10.1.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.7.4 (compiled with Erlang/OTP 21)
  • Operating system: MacOS Mojave 10.14.1 (18B75)

Current behavior

$ MIX_DEBUG=true mix help
** Running mix loadconfig (inside Api.Umbrella.MixProject)
** (ArgumentError) argument error
    (stdlib) eval_bits.erl:101: :eval_bits.eval_exp_field1/6
    (stdlib) eval_bits.erl:92: :eval_bits.eval_field/3
    (stdlib) eval_bits.erl:68: :eval_bits.expr_grp/4
    (stdlib) erl_eval.erl:484: :erl_eval.expr/5
    (stdlib) erl_eval.erl:888: :erl_eval.expr_list/6
    (stdlib) erl_eval.erl:240: :erl_eval.expr/5
    (stdlib) erl_eval.erl:232: :erl_eval.expr/5

Expected behavior

it should work.

Here's my mix.exs:

defmodule Api.Umbrella.MixProject do
  use Mix.Project

  def project do
    [
      apps_path: "apps",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

  # Dependencies can be Hex packages:
  #
  #   {:mydep, "~> 0.3.0"}
  #
  # Or git/path repositories:
  #
  #   {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
  #
  # Type "mix help deps" for more examples and options.
  #
  # Dependencies listed here are available only for this project
  # and cannot be accessed from applications inside the apps folder
  defp deps do
    [
      {:coverex, "~> 1.5.0", only: :test},
      {:credo, "~> 0.10.0", only: [:dev, :test], runtime: false},
      {:distillery, "~> 2.0"}
    ]
  end
end

Most helpful comment

@raarts this error message is super bad though. We will look into improving it directly in Erlang/OTP. Thanks!

All 6 comments

Hi @raarts, that should work indeed. :) I pasted the mix.exs file locally and it did it work. What is in your config/ files? In case you can't share it, because it has secrets and other stuff, does it work if you remove the config directory?

Alright, that fixes it. And helped me find the problem:

config :api_web, :myapp,
       app_id: System.get_env("OIDC_RESOURCE"),
       app_url: System.get_env("OIDC_BASEURL") <> "/" <> System.get_env("OIDC_REALM")

Of course the env var was not there. I make stupid errors all the time. Thanks for pointing me into the right direction.

@raarts this error message is super bad though. We will look into improving it directly in Erlang/OTP. Thanks!

@josevalim still the same unhelpful error message in 1.9

Same message here too.

Turns out you can't concat strings with <> in a config file.

@trbngr you can concat strings, what you can't do is concat nil with a string using <> which is what happens with the default phoenix config. the easiest fix is to always use the fallback syntax: System.get_env("APP_NAME", "fallback-value")

Was this page helpful?
0 / 5 - 0 ratings