Nerves Runtime Shell
A custom shell for debugging and running commands on Nerves devices in a bash-like environment.
Nerves devices typically only expose an Elixir or Erlang shell prompt. While
this is handy, some tasks are easier to run in a more bash-like shell
environment. The nerves_runtime shell provides a limited CLI that can be run
without leaving the Erlang runtime.
Here's an example of how to use access it:
iex(1)> [Ctrl+G]
User switch command
--> s sh
--> j
1 {erlang,apply,[#Fun<Elixir.IEx.CLI.1.112225073>,[]]}
2* {sh,start,[]}
--> c
Nerves Interactive Command Shell
Type Ctrl+G to exit the shell and return to Erlang job control.
This is not a normal shell, so try not to type Ctrl+C.
/srv/erlang[1]>There are a few caveats to using this shell for now:
For projects generated by
nerves_bootstrapprior to v0.5.0, the default behavior ofCtrl+C Ctrl+Cis to exit the Erlang VM and reboot or hang your system, depending on howerlinitis configured. For projects generated bynerves_bootstrapv0.5.0 or later, therel/vm.argsfile has the+Bcoption included, which allows the Erlang VM to respond to an interrupt generated byCtrl+C:iex(1)> # Press CTRL+C iex(2)> ** (EXIT) interrupted iex(2)> :timer.sleep(1_000_000_000) ** (EXIT) interrupted iex(2)> User switch command --> s sh --> c Nerves Interactive Command Shell Type Ctrl+G to exit the shell and return to Erlang job control. This is not a normal shell, so try not to type Ctrl+C. /srv/erlang[1]> ls releases lib /srv/erlang[2]> Interrupted /srv/erlang[2]> InterruptedIf you want to upgrade an existing project to have this new behavior, simply add
+Bcon a line before the-extraline inrel/vm.args. Or, as a workaround without making that change, start another shell usingCtrl+Gandkillthe offending program.Commands are run asynchronously. This is unexpected if you're used to a regular shell. For most commands, it's harmless. One side effect is that if a command changes the current directory, it could be that the prompt shows the wrong path.
Starting the shell on a remote node (for example, using
remsh) is not currently supported.
Installation
The package can be installed by adding nerves_runtime_shell to your list of dependencies in mix.exs:
def deps do
[
{:nerves_runtime_shell, "~> 0.1.0"}
]
end