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

Work around failing to start nerves_key when optional dep #55

Merged
merged 1 commit into from
Dec 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/nerves_hub_link/configurators/nerves_key.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ if Code.ensure_loaded?(NervesKey) do

@impl NervesHubLink.Configurator
def build(%Config{} = config) 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)

nk_opts = config.nerves_key || []

bus_num = nk_opts[:i2c_bus] || 1
Expand Down