From 0ccbe8b66c811f59216520d1e81428effc12c005 Mon Sep 17 00:00:00 2001 From: dl-alexandre <166029845+dl-alexandre@users.noreply.github.com> Date: Thu, 21 May 2026 19:03:09 -0700 Subject: [PATCH] fix: start IEx before connect handoff --- lib/mix/tasks/mob.connect.ex | 17 +++++++++++++---- test/mix/tasks/mob_connect_test.exs | 12 ++++++++++++ 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 test/mix/tasks/mob_connect_test.exs diff --git a/lib/mix/tasks/mob.connect.ex b/lib/mix/tasks/mob.connect.ex index d0b8233..7f79188 100644 --- a/lib/mix/tasks/mob.connect.ex +++ b/lib/mix/tasks/mob.connect.ex @@ -157,9 +157,18 @@ defmodule Mix.Tasks.Mob.Connect do end) # Hand off to IEx in this process — tunnels stay alive via adb daemon. - # `IEx.Server.run/1` is the documented programmatic-start surface - # (added in 1.8.0). The old `IEx.start/0` was internal and removed - # in 1.20-rc.4. - IEx.Server.run([]) + ensure_iex_started() + IEx.start() + end + + @doc false + def ensure_iex_started do + case Application.ensure_all_started(:iex) do + {:ok, _apps} -> + :ok + + {:error, {app, reason}} -> + Mix.raise("Failed to start #{inspect(app)} before launching IEx: #{inspect(reason)}") + end end end diff --git a/test/mix/tasks/mob_connect_test.exs b/test/mix/tasks/mob_connect_test.exs new file mode 100644 index 0000000..516bab1 --- /dev/null +++ b/test/mix/tasks/mob_connect_test.exs @@ -0,0 +1,12 @@ +defmodule Mix.Tasks.Mob.ConnectTest do + use ExUnit.Case, async: true + + alias Mix.Tasks.Mob.Connect + + test "ensure_iex_started/0 starts the IEx application" do + Application.stop(:iex) + + assert :ok = Connect.ensure_iex_started() + assert {:ok, _} = Application.ensure_all_started(:iex) + end +end