Skip to content

Commit

Permalink
work around failing to start nerves_key when optional dep
Browse files Browse the repository at this point in the history
  • Loading branch information
jjcarstens committed Dec 4, 2020
1 parent 6f8007e commit 275c1ee
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lib/nerves_hub_link/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ defmodule NervesHubLink.Application do
}

def start(_type, _args) do
_ = maybe_start_nerves_key()

config = Configurator.build()

children =
Expand All @@ -32,4 +34,18 @@ defmodule NervesHubLink.Application do
children
end
end

defp maybe_start_nerves_key() do
if Code.ensure_loaded?(NervesKey) do
# Because :nerves_key is an optional dep, it does not get added to
# .app resource files or may be started in the wrong order
# causing failures when calling code that is not yet started.
# So we explicitly tell the :nerves_key to start here to ensure
# its available when needed. This can be removed once the fix
# has been released
#
# See https://github.com/erlang/otp/pull/2675
Application.ensure_all_started(:nerves_key)
end
end
end

0 comments on commit 275c1ee

Please sign in to comment.