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()
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance










