Starting extra_applications from iex

I was playing around with moving some config files to YAML rather than JSON, and the library Im using requires that it is added to extra_applications.

The problem is that it is never started when I run iex -S mix so I get errors.

I did open a github issue, but it seems I missed this in the readme:

when running mix tasks that depends on other apps you need to manually ensure all the apps are started (by either calling Application.ensure_all_started(:myapp) or Mix.Task.run “app.start”, )

How do I apply that to the iex command above?

Can please go a bit more into detail which yaml lib you are using?

And also it would be nice if you could show a small project which reproduces the problem.

Im using https://hex.pm/packages/yaml_elixir for theYAML parsing.

So, at the moment I use this to load some constants from a JSON file and create functions for converting constants:

defmodule App.Const do
  @app_dir        File.cwd!
  @const_files    Path.wildcard("#{@app_dir}/lib/domain/**/constants.json")

  for filename <- @const_files do
    # Watch for changes and recompile
    @external_resource filename

    file_consts =
      filename
      |> File.read!
      |> Poison.decode!
    
    # Creates functions for each constant
    for {key, value} <- file_consts do
      # Skip comments - hacky but meh
      unless key === "//" do
        def encode(unquote(String.to_atom(key))), do: unquote(value)
        def decode(unquote(value)), do: unquote(String.to_atom(key))
      end
    end
  end
end

Basically I just wanted to try using YAML files for them - largely because they support comments and I wouldn’t have to do the hacky part above where I check for ‘//’ as the key (I then use the value as the comment)

Now, if I put it into a function, it works ok - I assue because everything is loaded up before I call it

def get_consts do
  path = Application.app_dir(:ctx_voip, "priv/constants.yml")
  file_consts = YamlElixir.read_from_file(path)
end

But just switching the file_consts = ... part out above results in an error, which is from the library not being loaded yet.