Debugger does not stop at the breakpoints in tests for Elixir 1.15.0 on OTP 25
Elixir and Erlang/OTP versions
Elixir 1.15.0 (compiled with Erlang/OTP 24) Elixir 1.15.0 (compiled with Erlang/OTP 25)
Erlang 25.3.2 Erlang 25.3.2.2
Operating system
macOS
Current behavior
Elixir does not stop on breakpoints, in shell.
Steps to reproduce:
- Use Erlang
25.3.2, or25.3.2.2and Elixir1.15.0. - Create new mix project
mix new test. - Add breakpoints to the
test/test_test.exsfile, like these:
defmodule TestTest do
use ExUnit.Case
doctest Test
test "greets the world" do
require IEx; IEx.pry
dbg()
assert Test.hello() == :world
end
end
- Run tests with either
iex --dbg pry -S mix testoriex -S mix test.
Debugged does not stop on the breakpoints, but prints this information:
Cannot pry #PID<0.145.0> at TestTest."test greets the world"/1 (test/test_test.exs:6). Is an IEx shell running?
It seems, it does not work for mix test. I was able to reach breakpoint with iex --dbg pry -S mix phx.server.
It works for Erlang 26.0.1 for tests too.
Expected behavior
Breakpoints should work in tests too.
Same here, was able to stop on breakpoint with $ iex -S mix test --trace on Elixir 1.14.0, Erlang 25.1.1
I'm not able to stop with dbg() in my application code with elixir 1.15.1-otp-26 and erlang 26.0.2.
I'm running the session with: iex --dbg pry -S mix phx.server
It stops but when pry is requested and the prompt shows: Allow? [Yn] it doesn't matter if you choose Y or n, same behaviour (n) is applied.
Anyone with the same problem here?
Can you please try on v1.15.4?
@josevalim I've tried with Elixir 1.15.4-otp-26 on my machine and the result is the same as @sergiorjsd mentioned.
My machine: MacBook M2 Pro, macOS Ventura 13.2.1, Phoenix 1.7.2
I am also encountering this same issue with:
elixir 1.15.5-otp-26 erlang 26.0.2
I cannot reproduce it on 1.15.7 with neither OTP 25 nor OTP 26. So if someone can provide the precise steps to reproduce, it will be appreciated.
Hi @josevalim I encounter the same problem with this repository: https://github.com/etalab/transport-site
Steps to reproduce:
- Install following README instructions – no need to feed with data, an empty database with just
mix ecto.createandmix ecto.migratedoes the job - Insert a
dbg()breakpoint in a page that doesn’t need data, like in theinfo_producteurfunction inapps/transport/lib/transport_web/controllers/page_controller.ex, writedbg()in the beggining of the function - Run with
iex --dbg pry -S mix phx.server - Access in your browser the page http://localhost:5000/infos_producteurs
Expected behaviour: it should stop in the local context and give access to a console in this context Observed behaviour: it prints previous variables in the terminal and then continues
I can observe it with the Elixir & Erlang versions in .tool_versions as well as with elixir 1.15.5-otp-26 and erlang 26.1.2
Updating Elixir from 1.15.4 to 1.15.7 fixed it for me, OTP 26.
@vdegove can you confirm it works on v1.15.7 for you?
@josevalim thanks for checking it out, unfortunately it doesn’t work with 1.15.7.
My .tool-versions look like this:
elixir 1.15.7-otp-26
erlang 26.1.2
I’m redacting the file transport-site/apps/transport/lib/transport_web/controllers/page_controller.ex like this:
def infos_producteurs(conn, _params) do
dbg() # Hi all!
conn
|> assign(:mailchimp_newsletter_url, Application.get_env(:transport, :mailchimp_newsletter_url))
|> render("infos_producteurs.html")
end
Then: iex --dbg pry -S mix phx.server
Open a browser, open the page http://localhost:5000/infos_producteurs
Result: the request goes through entirely without halting.
It does print things when it hits dbg():
binding() #=> [
_params: %{},
conn: %Plug.Conn{
adapter: {Plug.Cowboy.Conn, :...},
assigns: %{ … }
…
halted: false,
…
]
But doesn’t halt.
Perhaps I’m misunderstanding how I should use it, or there is something special in the project? The whole code is here https://github.com/etalab/transport-site/ so anybody can test.
I had the same issue, it seems to be working for me after upgrading to
elixir 1.15.7-otp-26
erlang 26.1.2
@vdegove because you have Kino as a dependency, Kino is changing the dbg_callback when it boots, and the default fallback does not fallback to pry. I will fix this on Kino side.
Wow, good debugging, thanks a lot for checking it, I’m glad the report helped :)