nerves_bootstrap
nerves_bootstrap copied to clipboard
Nerves vm.args.eex prevents proper application of cookie through config or env variables
Environment
-
Elixir version (
elixir -v
): 1.10.4 -
Nerves environment: (
mix nerves.env --info
) |nerves_bootstrap| Environment Package ListNo packages found |nerves_bootstrap| Loadpaths Start
Nerves environment MIX_TARGET: host MIX_ENV: dev
NERVES_SYSTEM is unset NERVES_TOOLCHAIN is unset |nerves_bootstrap| Environment Variable List target: host toolchain: unset system: unset app: …/05_elixir/edith
|nerves_bootstrap| Loadpaths End
- Additional information about your host, target hardware or environment that may help
Current behavior
Running a shoehorn release (on host) results in the cookie being read from $HOME/.erlang.cookie
instead of the one configured through the normal mix release means (config or env variable)
❯❯❯❯ RELEASE_BOOT_SCRIPT=shoehorn RELEASE_COOKIE=shoehorn _build/dev/rel/shoehorn/bin/shoehorn start_iex
heart_beat_kill_pid = 3244
heart_beat_timeout = 30
2021-04-26 15:15:47.218544 Multiple -mode given to erl, using the first, ~p
["embedded"]
Erlang/OTP 23 [erts-11.1.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe]
=WARNING REPORT==== 26-Apr-2021::15:15:47.218544 ===
Multiple -mode given to erl, using the first, ["embedded"]
[Shoehorn] Init app :nerves_runtime undefined. Skipping
[Shoehorn] Init app :vintage_net undefined. Skipping
:JKIIVXBQQLKXJEANCEZM
…
Removing the -setcookie
in vm.args.eex
resolves the issue and also doesn't seem to break releases run on targets. Mix releases are always started with an cookie set on the cli. A random cookie is generated when building the release unless a specific one is explicitly set.
Expected behavior
The cookie configured in mix.exs or via the env variables is correctly applied.
Nerves only uses Mix releases
to assist in creating firmware. Mix releases also creates shell scripts and batch scripts which aren't useful for Nerves. It looks like the shell scripts don't work. I can think of a few solutions:
-
Have the Nerves tooling erase the shell scripts as a post-release step to avoid any confusion that they might be used. @mobileoverlord and I have discussed coding up our own release generator to avoid using Mix releases. This seems like a step in this direction, even though neither of us is super-excited about coding it up.
-
Don't support hardcoding the cookie in the firmware at all. The effect would be to erase the line in vm.args as you suggest and then delete the line in the mix.exs that sets it. I'm a big fan of not hardcoding cookies in firmware, but it might cause confusion since mix release docs say that cookies can be set in the mix.exs. The Nerves core team discussed this a year or so ago. Perhaps we need to revisit.
I assume that the reason that you're making a mix release in a Nerves project is to debug something with Shoehorn. Otherwise, I'd think that you'd just run iex -S mix
or mix test
to run on the host. Is that right?
I assume that the reason that you're making a mix release in a Nerves project is to debug something with Shoehorn.
That's kinda the case. It's for creating tests for whatever the shoehorn handler is used for.
That is a very noble effort that I'd like to support. I will think more about this. I'm glad that the workaround for you is easy (i.e., delete the -setcookie
line), though.