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

benwilson512

Author of Craft GraphQL APIs in Elixir with Absinthe

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

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.

Where Next?

Popular in Questions Top

itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
tduccuong
Hi, is there any work on GUI with Elixir, that is similar to Electron/Javascript? My idea is to bundle Phoenix and BEAM into a single se...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
vac
Hi, I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New

Other popular topics Top

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
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
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
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? https://hexdocs.pm/ecto/Ecto.Repo.h...
New
josevalim
Hi everyone, One of the features added to Elixir early on to help integration with Erlang code was the idea of overridable function defi...
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New

We're in Beta

About us Mission Statement