alrigotto

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

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

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

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

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()

Where Next?

Popular in Questions Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
New
rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
earth10
Hi, I’m just starting to build a side-project with Elixir and Phoenix and doing some basic test with Elixir alone. What strikes me is th...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

Other popular topics Top

New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
AstonJ
Please see the new poll here: Which code editor or IDE do you use? (Poll) (2022 Edition) It’s been a while since we first asked this, I...
208 31307 143
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New

We're in Beta

About us Mission Statement