Nerves crash dump, error in config file by using capture

I’m doing something like this in my config/rpi3.exs:
config :leds, set: &Nerves.Leds.set/1

The reason I’m doing this is because I have a fake leds set in my host.exs.

But when I burn the firmware and boot the rpi3, I get an error:
Could not start kernel pid {application_controller} (error in config file “/srv/erlang/releases/0.1.0/sys.config” (4): syntax error before: Fun)

I guess the erlang config doesn’t like my capture? Does anyone have an idea how to solve this?

Also, does anyone know how to get to the crash.dump file that nerves creates? This crash occurs on boot and as soon as the system crashes everything reboots. To read the error message I had to take a picture of it. There has to be a better way to do this?

Not sure if you can put function references like that in config files. Is this your own config setting or that of a library’s? You can do this instead:

config :leds, set: {Nerves.Leds, :set}

And then in your code you can do

{module, function} = Application.get_env(:leds, :set)

# To call the function set in config
apply(module, function, [your_args])

Sorry to necro-bump, but wanted to leave a bread-crumb here for future visitors looking for where the crash dump ends up. I think @Nicd’s solution is a good way to go. I’ve never considered trying to capture a function in a config file like that, but I’ve certainly tried using a Struct, which also doesn’t work because the config is processed at compile time, so it doesn’t have access to them.

You can configure the ERL_CRASH_DUMP setting in your erlinit.config file using a rootfs_overlay if you want to change it, but by default in the official systems, it’s set to /root/crash.dump. This is the root user’s home directory, mounted on the read/write application data partition (unless you’ve overridden that in your fwup.conf)

1 Like