How do I start a phoenix app within visual studio code? I am using VSC with the elixir-ls plugin. When I try to start debugging with “mix phx.server”, the debugging-console writes:
Started ElixirLS debugger
Elixir version: "1.7.1 (compiled with Erlang/OTP 19)"
Erlang version: "19"
but nothing more happens.
I’ve added this to the list of “configurations” in my launch.json file of my project.
To be more precise, starting the server with “mix phx.server” right from the command line works. I just want to get it working within the debugging tool of VSC.
Sorry, it’s not that my problem is resolved. My previous message said that I have tried what the page said and changed “mix test” to “mix phx.server” because the page doesn’t deal with phoenix.
What I then get is
Started ElixirLS debugger
Elixir version: "1.7.1 (compiled with Erlang/OTP 19)"
Erlang version: "19"
I created a new phoenix app with ‘mix phx.new testit --no-ecto’ (I am using Windows 10).
This time I get an error:
Started ElixirLS debugger
Elixir version: "1.7.1 (compiled with Erlang/OTP 19)"
Erlang version: "19"
[warn] Phoenix is unable to create symlinks. Phoenix' code reloader will run considerably faster if symlinks are allowed. On Windows, the lack of symlinks may even cause empty assets to be served. Luckily, you can address this issue by starting your Windows terminal at least once with "Run as Administrator" and then running your Phoenix application.
[info] Application testit exited: Testit.Application.start(:normal, []) returned an error: shutdown: failed to start child: TestitWeb.Endpoint
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, TestitWeb.Endpoint.HTTP}
** (EXIT) an exception was raised:
** (ArgumentError) argument error
(phoenix) Elixir.Phoenix.Endpoint.Cowboy2Adapter.erl:69: Phoenix.Endpoint.Cowboy2Adapter.info/3
(phoenix) Elixir.Phoenix.Endpoint.Cowboy2Adapter.erl:54: Phoenix.Endpoint.Cowboy2Adapter.start_link/3
(Debugger) Task failed because an exception was raised:
** (Mix.Error) Could not start application testit: Testit.Application.start(:normal, []) returned an error: shutdown: failed to start child: TestitWeb.Endpoint
** (EXIT) shutdown: failed to start child: {:ranch_listener_sup, TestitWeb.Endpoint.HTTP}
** (EXIT) an exception was raised:
** (ArgumentError) argument error
(phoenix) Elixir.Phoenix.Endpoint.Cowboy2Adapter.erl:69: Phoenix.Endpoint.Cowboy2Adapter.info/3
(phoenix) Elixir.Phoenix.Endpoint.Cowboy2Adapter.erl:54: Phoenix.Endpoint.Cowboy2Adapter.start_link/3
(mix) lib/mix.ex:323: Mix.raise/1
(elixir) lib/enum.ex:765: Enum."-each/2-lists^foreach/1-0-"/2
(elixir) lib/enum.ex:765: Enum.each/2
(mix) lib/mix/tasks/app.start.ex:114: Mix.Tasks.App.Start.start/2
(mix) lib/mix/tasks/app.start.ex:86: Mix.Tasks.App.Start.run/1
(mix) lib/mix/task.ex:316: Mix.Task.run_task/3
(mix) lib/mix/tasks/run.ex:129: Mix.Tasks.Run.run/5
Node is installed. As I wrote, starting the server from command line works.
Less than in other languages. Stopping a process and single-stepping it, while the process that calls it times out, is still useful for understanding what the code in one process does. But that kind of thing is less useful for the highly-concurrent OTP style of program, so I think stepping in a debugger is more of a beginner’s technique, not relied on once you’ve got a better understanding of how things work.
That said, without the debugger, I would NEVER have figured out what was going on when a bug in PostgreSQL’s parser broke postgrex. Yeah, I know, the last place in the world I would look for a bug.
In case it’s not clear from my previous message, I fully agree that a visual debugger is needed for the environment, especially to help newcomers wrap their heads around Elixir. Just trying to point out why it’s less emphasized…
I’m on a macbook so there may be some windows things to work out, but I think that should get you most of the way there. I did a mix phx.new on the latest version, and this configuration allowed me to successfully launch the debugger.