I have a Phoenix app that I migrated from an Intel Mac to an M1 Mac that no longer works, despite that fact that both Elixir and Erlang seem to be working fine:
% elixir -v
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]
Elixir 1.15.2 (compiled with Erlang/OTP 26)
% erl -v
Erlang/OTP 26 [erts-14.0.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]
Eshell V14.0.2 (press Ctrl+G to abort, type help(). for help)
1>
Here’s what happens when I try to start my app with iex:
% iex -S mix phx.server
11:41:49.298 [notice] Application ssl exited: exited in: :ssl_app.start(:normal, [])
** (EXIT) an exception was raised:
** (ArgumentError) could not call Module.put_attribute/3 because the module Myapp.MixProject is already compiled
(elixir 1.15.2) lib/module.ex:2310: Module.assert_not_readonly!/2
(elixir 1.15.2) lib/module.ex:2007: Module.__put_attribute__/5
(ssl 11.0.2) ssl_app.erl:35: :ssl_app.stop/1
(kernel 9.0.2) application_master.erl:293: :application_master.start_it_old/4
11:41:49.306 [notice] Application public_key exited: :stopped
11:41:49.306 [notice] Application asn1 exited: :stopped
11:41:49.307 [notice] Application crypto exited: :stopped
Could not start Hex. Try fetching a new version with "mix local.hex" or uninstalling it with "mix archive.uninstall hex.ez"
** (MatchError) no match of right hand side value: {:error, {:ssl, {:bad_return, {{:ssl_app, :start, [:normal, []]}, {:EXIT, {%ArgumentError{message: "could not call Module.put_attribute/3 because the module Myapp.MixProject is already compiled"}, [{Module, :assert_not_readonly!, 2, [file: ~c"lib/module.ex", line: 2310]}, {Module, :__put_attribute__, 5, [file: ~c"lib/module.ex", line: 2007]}, {:ssl_app, :stop, 1, [file: ~c"ssl_app.erl", line: 35]}, {:application_master, :start_it_old, 4, [file: ~c"application_master.erl", line: 293]}]}}}}}}
(hex 2.0.6) lib/hex.ex:5: Hex.start/0
(mix 1.15.2) lib/mix/hex.ex:60: Mix.Hex.start/0
(mix 1.15.2) lib/mix/dep/loader.ex:189: Mix.Dep.Loader.with_scm_and_app/5
(mix 1.15.2) lib/mix/dep/loader.ex:141: Mix.Dep.Loader.to_dep/4
(elixir 1.15.2) lib/enum.ex:1693: Enum."-map/2-lists^map/1-1-"/2
(mix 1.15.2) lib/mix/dep/loader.ex:364: Mix.Dep.Loader.mix_children/3
(mix 1.15.2) lib/mix/dep/loader.ex:18: Mix.Dep.Loader.children/1
(mix 1.15.2) lib/mix/dep/converger.ex:105: Mix.Dep.Converger.all/4
I get the same error if I run mix local.hex
as it suggests. When I try the uninstall suggestion I get the following:
% mix archive.uninstall hex.ez
zsh: illegal hardware instruction mix archive.uninstall hex.ez
Any ideas? It sounds like some thing is wrong with the migrated application but I can’t work out what.
Any ideas?