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

Running mix compile.nerves_package crashes #927

Closed
Noarkhh opened this issue Nov 6, 2023 · 3 comments · Fixed by #928
Closed

Running mix compile.nerves_package crashes #927

Noarkhh opened this issue Nov 6, 2023 · 3 comments · Fixed by #928

Comments

@Noarkhh
Copy link

Noarkhh commented Nov 6, 2023

Environment

  • Elixir version: 1.15.6
  • Nerves environment: rpi4, dev
  • Host OS: MacOS and Ubuntu

Current behavior

After running mix compile.nerves_package in a new project the compilation crashes:

mix nerves.new test
cd test
export MIX_TARGET=rpi4
mix deps.get
mix compile.nerves_package

stacktrace:

** (KeyError) key :type not found in: nil

If you are using the dot syntax, such as map.field, make sure the left-hand side of the dot is a map
    (nerves 1.10.4) lib/nerves/artifact.ex:210: Nerves.Artifact.env_var/1
    (nerves 1.10.4) lib/nerves/artifact.ex:200: Nerves.Artifact.env_var?/1
    (nerves 1.10.4) lib/nerves/artifact.ex:89: Nerves.Artifact.stale?/1
    (nerves 1.10.4) lib/mix/tasks/compile.nerves_package.ex:28: Mix.Tasks.Compile.NervesPackage.run/1
    (mix 1.15.6) lib/mix/task.ex:447: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.15.6) lib/mix/cli.ex:92: Mix.CLI.run_task/2
@fhunleth
Copy link
Member

fhunleth commented Nov 6, 2023

Could you run mix firmware?

Out of curiosity, where are you seeing the reference to mix compile.nerves_package? We need to fix this, but it's not the normal way to use Nerves, so I'd like to update that reference. Thank you for reporting it!

jjcarstens added a commit that referenced this issue Nov 8, 2023
Fixes #927

This previously ignored the return of `Nerves.Env.ensure_loaded/1` which
could actually return an `{:error, _}` tuple. When calling the
`compile.nerves_package` manually, it would crash with a confusing error.

This instead checks the return and raises on error.

It also adjusts the documentation on how/when this task is used
jjcarstens added a commit that referenced this issue Nov 8, 2023
Fixes #927

This previously ignored the return of `Nerves.Env.ensure_loaded/1` which
could actually return an `{:error, _}` tuple. When calling the
`compile.nerves_package` manually, it would crash with a confusing error.

This instead checks the return and raises on error.

It also adjusts the documentation on how/when this task is used
@Noarkhh
Copy link
Author

Noarkhh commented Nov 11, 2023

Hi, thanks for quick response!

I found it here, in the official documentation. I guess some broader documentation could be useful. I was messing around with tasks when trying to locate binaries not contained within the artifact located in ~/.nerves/artifacts/<my_artifact>/, but present in the generated firmware. Would it be possible for you to lend me a hand in this regard? If so you can suggest an appropriate place to continue our conversation.

@fhunleth
Copy link
Member

Got it. Thanks. I refreshed the hexdocs to include @jjcarstens's documentation fix.

The best places to go for help are to either post something on the Elixir forum (add the Nerves label for someone to see it) or join the Elixir Discord or Slack and post to the #nerves channel.

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

Successfully merging a pull request may close this issue.

2 participants