igniter icon indicating copy to clipboard operation
igniter copied to clipboard

mix igniter.install fails when dependency is resolved from Hex

Open spapiernik opened this issue 7 months ago • 1 comments

Code of Conduct

  • [x] I agree to follow this project's Code of Conduct

AI Policy

  • [x] I agree to follow this project's AI Policy, or I agree that AI was not used while creating this issue.

Versions

Elixir: 1.20.0-rc.4-otp-28, 1.19.5-otp-28, 1.18.4-otp-28 Erlang: 28.3

Operating system

WSL Debian 13

Current Behavior

Running mix igniter.install phoenix_sync --sync-mode embedded --no-sync-sandbox fails with

(UndefinedFunctionError) function Phoenix.Sync.MixProject.project/0 is undefined (module Phoenix.Sync.MixProject is not available)

when the dependency is resolved from Hex.

The installation process calls Phoenix.Sync.MixProject.project/0 to read dependency information from the package's mix.exs:

https://github.com/electric-sql/phoenix_sync/blob/aaeaef7842a40e937c616504e61fb568fd28efc4/lib/mix/tasks/phoenix_sync.install.ex#L300

This call is where the error is raised

Using a local path for the same package does not produce this error:

git clone https://github.com/electric-sql/phoenix_sync.git
mix phx.new my_app
cd my_app
mix igniter.install phoenix_sync@path:../phoenix_sync --sync-mode embedded --no-sync-sandbox

Using a GitHub reference for the same package also does not produce this error:

mix phx.new my_app
cd my_app
mix igniter.install phoenix_sync@github:electric-sql/phoenix_sync --sync-mode embedded --no-sync-sandbox

Reproduction

Run the following commands:

mix phx.new my_app
cd my_app
mix igniter.install phoenix_sync --sync-mode embedded --no-sync-sandbox

Expected Behavior

The installation should complete without errors when the dependency is resolved from Hex.

spapiernik avatar Apr 13 '26 01:04 spapiernik

I'm not sure why this works when installed from github TBH, but the issue is here:

defp required_electric_version do
  Phoenix.Sync.MixProject.project()
  |> Keyword.fetch!(:deps)
  |> Enum.find(&match?({:electric, _, _}, &1))
  |> elem(1)
end

that module wouldn't be available/defined inside the "target" application. You'd want to use a module attribute for example and compile that in as opposed to accessing it at runtime during install. LMK if you have any issues around that/need any other assistance!

zachdaniel avatar Apr 13 '26 03:04 zachdaniel