alrigotto
I can't type anything in terminal when I run my app with "iex -S mix"
Hi guys!
I’m a beginner user in Elixir. I wrote a small program using Mix project. It’s work fine when I run my app with “mix run”, but when I use “iex -S mix” (for debug) I can’t type anything in terminal and I need to use ctrl+C for exit.
Most Liked
stevensonmt
No idea what is going on there. Are you calling iex -S mix from within the root directory of your project? Are you able to just run iex normally?
benwilson512
Hey @alrigotto welcome! This usually means that one of your supervisor’s children has hung and so the app is unable to boot. If you do iex -S mix run --no-start do you get a REPL? Can you show your application.ex file?
Eiji
Looks like you use this code at application start.
That’s good for normal app start or script, but when your are using iex then IO.gets/1 is blocking shell. Running the game in supervised task also does not solves the problem.
The only way to “play” a game in iex (using IO.gets/1) is to call the code directly from shell instead of adding it to application supervisor tree. However in that case when starting app normally the game would not run.
Therefore I would suggest to check some args/environment variables, so for some runs simply start the game automatically and when using iex shell start the game manually, for example:
defmodule GuessGame do
use Application
def start(_,_) do
if some_check_here do
run()
end
{:ok, self()}
end
# …
end
iex> GuessGame.run()
benwilson512
I could be wrong but I’m pretty sure that returning {:ok, self()} from start is also a problem. The application root needs to be an actual supervisor, not whatever pid is booting the app.
jjenkins
Also, might I suggest using the 1.14 version of elixir and the new dbg features?
The IEX+dbg and pipeline debugging will make your live much better, and remove the need for the many inspects.
The videos on that link give a view of how it can help you.







