I literally have just started my first nerves project and thought it would be nice to get the observer up and running on the node.
I have run ‘ssh -X nerves.local’ to get to the node and that takes me to the node with the X forwarding configured.
The observer doesn’t start as it is not recognised.
(UndefinedFunctionError) function :observer.start/0 is undefined (module :observer is not available)
Can this be included in my firmware? No obvious web searches have found a solution.
Observer uses a GUI framework called Wx, and Wx doesn’t crosscompile. That means it’s unavailable for use on a Nerves device.
The good news is that Observer also works via Erlang distribution. This is a better way in almost all respects since the GUI runs directly on your laptop. Erlang distribution isn’t started by default. There are many ways of doing this, but I think the one described in the
nerves_pack docs is good for one-off uses.
ssh into the device and run the following:
iex> System.cmd("epmd", ["-daemon"])
Then on your laptop, start
$ iex --name firstname.lastname@example.org --cookie my_secret_cookie
Erlang/OTP 23 [erts-11.0.2] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe]
Interactive Elixir (1.10.3) - press Ctrl+C to exit (type h() ENTER for help)
You should see an Observer window. Go to the Nodes menu, then Connect Node. Connect to
nerves.local. If all goes well, you should see the CPU count and “compiled for” change change. Observer is now getting all of its data from the device.
A note on
nerves.local: This is one of the mDNS names that Nerves devices advertise by default. If you type
hostname on the device or explore the network with an mDNS browser, you can see the other one. On my device, it’s
nerves-19d1.local. If you have multiple Nerves devices, you can no longer use
nerves.local. Some people have trouble with mDNS and use IP addresses for Erlang distribution. The key is to make sure that the name that you use on the device (
email@example.com) matches what you use in the Observer UI since if you don’t, you’ll get an error (probably a pang) and it might not be obvious what to do.
Many thanks for this detailed answer.