phoenix_sync icon indicating copy to clipboard operation
phoenix_sync copied to clipboard

`mix igniter.install phoenix_sync --sync-mode embedded` fails on first run but succeeds on second run

Open spapiernik opened this issue 8 months ago • 0 comments

Environment

  • Elixir: 1.20.0-rc.4-otp-28, 1.19.5-otp-28, 1.18.4-otp-28
  • Phoenix: 1.7.x
  • Phoenix.Sync: 0.6.1
  • igniter: 0.7.7

What I did

  1. Created a new project:
mix phx.new hello
  1. Added igniter to mix.exs:
{:igniter, "~> 0.6", only: [:dev, :test]}
  1. Then ran:
mix igniter.install phoenix_sync --sync-mode embedded

First run result (FAILS)

Igniter adds phoenix_sync to mix.exs and compiles it, but then crashes with:

** (UndefinedFunctionError) function Phoenix.Sync.MixProject.project/0 is undefined (module Phoenix.Sync.MixProject is not available)
    Phoenix.Sync.MixProject.project()
    (phoenix_sync 0.6.1) lib/mix/tasks/phoenix_sync.install.ex:301: Mix.Tasks.PhoenixSync.Install.required_electric_version/0
    (phoenix_sync 0.6.1) lib/mix/tasks/phoenix_sync.install.ex:123: Mix.Tasks.PhoenixSync.Install.add_dependencies/2
    (igniter 0.7.7) lib/igniter/util/install.ex:187: anonymous fn/3 in Igniter.Util.Install.run_installers/5
    (elixir 1.20.0-rc.4) lib/enum.ex:2617: Enum."-reduce/3-lists^foldl/2-0-"/3
    (igniter 0.7.7) lib/igniter/util/install.ex:176: Igniter.Util.Install.run_installers/5
    (mix 1.20.0-rc.4) lib/mix/task.ex:502: anonymous fn/3 in Mix.Task.run_task/5
    (mix 1.20.0-rc.4) lib/mix/cli.ex:129: Mix.CLI.run_task/2

At this point:

  • phoenix_sync has already been added to deps
  • but the installer crashes before finishing

Second run (WORKS)

Without changing anything else, I run:

mix igniter.install phoenix_sync --sync-mode embedded

Now it succeeds:

  • Detects phoenix_sync already installed
  • Adds :electric
  • Runs phoenix_sync.install
  • Updates config and application files correctly

Observed behavior

  • First run fails because Phoenix.Sync.MixProject is not available https://github.com/electric-sql/phoenix_sync/blob/aaeaef7842a40e937c616504e61fb568fd28efc4/lib/mix/tasks/phoenix_sync.install.ex#L301
  • Second run succeeds once the dependency is already compiled

What I expected

  • mix igniter.install phoenix_sync --sync-mode embedded to succeed on the first run

spapiernik avatar Apr 01 '26 20:04 spapiernik