Sometimes you might accidentally run something in the shell that ends up waiting forever, and thus blocking the shell:
iex(2)> receive do _ -> :stuck end
In that case, press Ctrl-g. You'll see:
User switch command
Enter these commands in order:
k
(to kill the shell process)s
(to start a new shell process)c
(to connect to the new shell process)You'll end up in a new Erlang shell:
Eshell V8.0.2 (abort with ^G)
1>
To start an Elixir shell, type:
'Elixir.IEx.CLI':local_start().
(don't forget the final dot!)
Then you'll see a new Elixir shell process coming up:
Interactive Elixir (1.3.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> "I'm back"
"I'm back"
iex(2)>
To escape from “awaiting-for-more-input” mode (due to unclosed quotation mark, bracket etc,) type #iex:break
, followed by carriage return (⏎):
iex(1)> "Hello, "world"
...(1)>
...(1)> #iex:break
** (TokenMissingError) iex:1: incomplete expression
iex(1)>
the above is specifically useful when copy-pasting a relatively huge snippet turns the console to “awaiting-for-more-input” mode.