Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

module Toml.Provider is not available #15

Closed
absolut777 opened this issue Mar 21, 2019 · 4 comments
Closed

module Toml.Provider is not available #15

absolut777 opened this issue Mar 21, 2019 · 4 comments

Comments

@absolut777
Copy link

First of all thank you very much for you work. Live with default erlang's sys.config is terrible:)

I'm trying to use toml with distillery and getting the error when start an application:

/home/app/my_app/bin/my_app start
init terminating in do_boot ({,[{Elixir.Toml.Provider,init,[[_]],[]},{Elixir.Mix.Releases.Config.Provider,-init/1-fun-0-,2,[{_},{_}]},{Elixir.Enum,-reduce/3-lists^foldl/2-0-,3,[{_},{_}]},{Elixir.Mix.R

Crash dump is being written to: erl_crash.dump...done
function Toml.Provider.init/1 is undefined (module Toml.Provider is not available)
    Toml.Provider.init([path: "/etc/my_app/config.toml"])
    (distillery) lib/mix/lib/releases/config/provider.ex:45: anonymous fn/2 in Mix.Releases.Config.Provider.init/1
    (elixir) lib/enum.ex:1940: Enum."-reduce/3-lists^foldl/2-0-"/3
    (distillery) lib/mix/lib/releases/config/provider.ex:38: Mix.Releases.Config.Provider.init/1
    :init.eval_script/2
    :init.do_boot/3

{"init terminating in do_boot",{#{'__exception__'=>true,'__struct__'=>'Elixir.UndefinedFunctionError',arity=>1,function=>init,message=>nil,module=>'Elixir.Toml.Provider',reason=>nil},[{'Elixir.Toml.Provider',init,[[{path,<<"/etc/my_app/config.toml">>}]],[]},{'Elixir.Mix.Releases.Config.Provider','-init/1-fun-0-',2,[{file,"lib/mix/lib/releases/config/provider.ex"},{line,45}]},{'Elixir.Enum','-reduce/3-lists^foldl/2-0-',3,[{file,"lib/enum.ex"},{line,1940}]},{'Elixir.Mix.Releases.Config.Provider',init,1,[{file,"lib/mix/lib/releases/config/provider.ex"},{line,38}]},{init,eval_script,2,[]},{init,do_boot,3,[]}]}}
Unable to configure release!

Release was build with commands:

mix deps.get
MIX_ENV=prod mix release

It seems toml is not included in release and I don't realise why. My environment is below:

mix.exs:

Code.require_file("lib/mix/vectors.exs", __DIR__)

defmodule CtiOmniUmbrella.MixProject do
  use Mix.Project
  import CtiOmniUmbrella.MixProject.Vectors

  def project do
    [
      elixir: "~> 1.8",
      apps_path: "apps",
      start_permanent: Mix.env() == :prod,
      deps: deps(),
      aliases: aliases(),
      test_coverage: [tool: ExCoveralls],
      preferred_cli_env: [
        coveralls: :test,
        "coveralls.detail": :test,
        "coveralls.post": :test,
        "coveralls.html": :test
      ],
      apps: apps(System.get_env("VECTOR")) ++ extra_apps(System.get_env("VECTOR_EXTRA_APPS")),
      aliases: aliases()
    ]
  end

  # nd Dependencies listed here are available only for this
  # project and cannot be accessed from applications inside
  # the apps folder.
  #
  # Run "mix help deps" for examples and options.
  defp deps do
    [
      {:toml, "~> 0.5"},
      {:distillery, "~> 2.0.12", runtime: true},
      {:bootleg, github: "virviil/bootleg", override: true},
      {:bootleg_phoenix, "~> 0.2"}
    ]
  end

  defp aliases do
    [
      "run.my_app": [
        fn _ ->
          :os.cmd('pushd apps/my_app')
        end,
        "phx.server",
        fn _ ->
          :os.cmd('popd')
        end
      ],
      "format.all": [
        "format mix.exs \"apps/**/lib/**/*.{ex,exs}\" \"apps/**/test/**/*.{ex,exs}\" \"apps/**/config/**/*.{ex,exs}\" \"config/**/*.{ex,exs}\""
      ]
    ]
  end
end

rel/config.exs:

# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
Path.join(["rel", "plugins", "*.exs"])
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))

# This sets the default release built by `mix release`
# This sets the default environment used by `mix release`
use Mix.Releases.Config,
  default_release: :default,
  default_environment: Mix.env()

# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/configuration.html

# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile
environment :dev do
  set(dev_mode: true)
  set(include_erts: false)
  set(cookie: :"K}Qhp5,M6&cv5W:Q^](/P|uU$y]zf^DS.P<8QzsC8`%VHnVtdw>|gU?.2xqX)8SW")
end

environment :stage1 do
  set(include_erts: true)
  set(include_system_libs: true)
  set(include_src: false)
end
environment :prod do
  set(include_erts: true)
  set(include_src: false)
  set(cookie: :my_app)
end

# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default

release :my_app do
  set(version: current_version(:my_app))

  set config_providers: [
    {Toml.Provider, [path: "/etc/my_app/config.toml"]}
  ]

  set(
    applications: [
      :runtime_tools,
      :my_app,
      :eventbus,
      :router,
#      :router_2,
#      :router_3,
#      :app_4
    ]
  )

  set(
    commands: [
      migrate: "rel/commands/migrate.sh",
      rollback: "rel/commands/rollback.sh",
      seed: "rel/commands/seed.sh",
    ]
  )

  set overlays: [
    {:copy, "apps/my_app/cti-omni-logging.conf", "cti-omni-logging.conf"},
    {:copy, "version", "version"}
  ]

end

Elixir 1.8.1
Erlang 21.2.3
CentOS 7.4

@djthread
Copy link

djthread commented Apr 8, 2019

Hm! I've also ran into this one. I tried cleaning out _build... This app used to build and run with distillery...

My Dockerfile is here. https://github.com/djthread/lucidboard/blob/master/assets/ops/release/Dockerfile

@Awlexus
Copy link

Awlexus commented Apr 8, 2019

I don't know if it's the case for you, but my coworker found out, that I forgot to include toml in the list of included applications in mix.exs

@djthread
Copy link

djthread commented Apr 9, 2019

Nice! Thank you, @Awlexus. Adding :toml to my mix.exs's :extra_applications seemed to do the trick.

@absolut777
Copy link
Author

It works with :extra_applications. Thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants