Phoenix app not starting on nerves build

I have an umbrella app with three different OTP apps within it. One of these is a phoenix web app and the other two are a back-end app that handles a DETS table and the other is a nerves firmware app. I tried to follow the guide in the documentation, but it does not seem to work or be compatible with elixir 1.10. When I flashed the image to an SD card and put it into my raspberry pi 4, it booted into an iex shell and was running the firmware app, and nothing else. However, the code that was compiled for the other umbrella applications was included and I was able to call some functions that I wrote in the other umbrella dependencies. So how can I get all the apps to run on my nerves device?

EDIT
To clarify, it was running the firmware app and other OTP apps that were specified in the Mix file except for the umbrella dependencies.

Nerves 1.6 supports Elixir 1.10. Did you receive an error?

Also, could you check the log messages on the device? Perhaps there’s something helpful there. (at the IEx prompt, run RingLogger.next)

I meant that the documentation for using nerves in an umbrella project was not compatible with elixir 1.10.

Elixir 1.10 umbrellas changed how they handle loading the Mix configuration.

In Elixir <= 1.9.x umbrella applications Mix config would point the config to config_path: "../../config/config.exs" which in turn would load the apps/*/config/config.exs files. This configuration often led to problems due to the way that Nerves interfaces with Mix. Its a common pattern that when compiling for a target you have an explicit configuration file that can be the final override. In our projects, this is the config/target.exs file, by default it is evaluated last. In umbrellas, the app/*/config/config.exs files would be evaluated in alphabetical order, which was confusing. With Elixir <= 1.10.0, the config/config.exs file in the top of the umbrella no longer references the individual apps, but this lends itself to a new problem, how do we package the nerves specific config files with the new project generator without clobbering the umbrella config with required configuration.

I think the right answer here is to update the new project generator to not change the location of config_path in the Mix config and always point to the included config. I’ve always struggled to find value in using a Nerves app in an umbrella. In addition to the config, a big complication is the use of Mix aliases. Nerves uses Mix aliases to bootstrap the environment for cross compilation. The issue is that Mix aliases are only invoked for the top level mix project, meaning, all mix commands that are run at the top of the umbrella would not invoke nerves_bootstrap, and you would therefore have to cd to the app dir. Alternatively, the aliases could be added to the umbrella’s mix,exs file, but that would then have an opposite effect where all apps would be cross compiled (native code).

2 Likes