Cannot enter pry prompt with dbg or IEx.pry()

Here is my output:

Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)

Rebuilding...

Done in 253ms.
[info] GET /
[debug] Processing with DemoWeb.PageController.home/2
  Parameters: %{}
  Pipelines: [:browser]
Request to pry #PID<0.664.0> at DemoWeb.PageController.foo/1 (lib/demo_web/controllers/page_controller.ex:18)

Request to pry #PID<0.664.0> at DemoWeb.PageController.foo/1 (lib/demo_web/controllers/page_controller.ex:18)
   15:     |> String.split()
   16:     |> Enum.count()
   17:     |> IO.inspect()
   18:     |> dbg
   19:
   20:     conn
   21:   end
Allow? [Yn] y

Interactive Elixir (1.16.2) - press Ctrl+C to exit (type h() ENTER for help)
iex(1)> whereami
Location: lib/demo_web/controllers/page_controller.ex:18

   16:     |> Enum.count()
   17:     |> IO.inspect()
   18:     |> dbg
   19:
   20:     conn

    (demo 0.1.0) lib/demo_web/controllers/page_controller.ex:18: DemoWeb.PageController.foo/1
    (demo 0.1.0) lib/demo_web/controllers/page_controller.ex:9: DemoWeb.PageController.home/2
    (demo 0.1.0) lib/demo_web/controllers/page_controller.ex:1: DemoWeb.PageController.action/2
    (demo 0.1.0) lib/demo_web/controllers/page_controller.ex:1: DemoWeb.PageController.phoenix_controller_pipeline/2
    (phoenix 1.7.11) lib/phoenix/router.ex:484: Phoenix.Router.__call__/5
    (demo 0.1.0) lib/demo_web/endpoint.ex:1: DemoWeb.Endpoint.plug_builder_call/2
    (demo 0.1.0) deps/plug/lib/plug/debugger.ex:136: DemoWeb.Endpoint."call (overridable 3)"/2
    (demo 0.1.0) lib/demo_web/endpoint.ex:1: DemoWeb.Endpoint.call/2
    (phoenix 1.7.11) lib/phoenix/endpoint/sync_code_reload_plug.ex:22: Phoenix.Endpoint.SyncCodeReloadPlug.do_call/4
    (bandit 1.4.1) lib/bandit/pipeline.ex:150: Bandit.Pipeline.call_plug!/2
    (bandit 1.4.1) lib/bandit/pipeline.ex:36: Bandit.Pipeline.run/4
    (bandit 1.4.1) lib/bandit/http1/handler.ex:12: Bandit.HTTP1.Handler.handle_data/3
    (bandit 1.4.1) lib/bandit/delegating_handler.ex:18: Bandit.DelegatingHandler.handle_data/3
    (bandit 1.4.1) /pry/deps/thousand_island/lib/thousand_island/handler.ex:411: Bandit.DelegatingHandler.handle_continue/2
    (stdlib 5.2.1) gen_server.erl:1085: :gen_server.try_handle_continue/3
    (stdlib 5.2.1) gen_server.erl:995: :gen_server.loop/7
    (stdlib 5.2.1) proc_lib.erl:241: :proc_lib.init_p_do_apply/3

iex(2)>

Have taken it from container:

  • Started the application
  • Visited http://localhost:4000 in browser.
  • Reached a breakpoint, pressed Y
  • got into debugger. The debugger did not change the prompt to pry>, but kept iex> one.
  • I was able to run debugging-related commands (for example whereami) in the context of debugged process, though the prompt is still iex>.

Great, that it is not the case.

I see from your example, that you have reached the breakpoint in Elixir 1.16 too. Can you enter debugger-related commands from there (for example whereami)? If yes, then your debugger is working.

Do I understand correctly, that you expected to see the pry> prompt instead of iex> there (and thought pry did not work)?

1 Like