From dbe1a9fd717e0272a2f0bc9816dea4281e2b2f0a Mon Sep 17 00:00:00 2001 From: Noemi <45180344+unflxw@users.noreply.github.com> Date: Wed, 19 Mar 2025 10:11:14 +0100 Subject: [PATCH] Prevent install from running in test env In Elixir 1.18, `mix test` will attempt to re-run the installation Mix task again. As it's running in test mode, the modules it depends on will have been stubbed out by our test config. But the processes for those modules have not been started yet, so the task crashes. Guard against this when the task starts and bail out if in test env. WARNING: This is a draft to work around the issue. I have no idea what unintended effects this has -- can the tests for the helper task even run now? Do not merge this without further testing. --- mix_helpers.exs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mix_helpers.exs b/mix_helpers.exs index 3636cc08f..d92eff332 100644 --- a/mix_helpers.exs +++ b/mix_helpers.exs @@ -22,6 +22,15 @@ defmodule Mix.Appsignal.Helper do require Logger def install do + if Enum.member?([:bench, :test, :test_no_nif], Mix.env()) do + Mix.shell().info("AppSignal: Skipping agent installation in test environment") + :ok + else + do_install() + end + end + + def do_install do report = initial_report() case verify_system_architecture(report) do