Fresh install + new project + mix test causes crash (1.14.3)

I’ve come back to Elixir after a year away. MacOS 12.4, M1 chip. Upgraded (see below for details).

After a mix new, I cd into the project and type mix test, to this result:

** (MatchError) no match of right hand side value: {:error, {{:EXIT, {:function_clause, [{:disk_log_sup, :start_link, [], [file: 'disk_log_sup.erl', line: 26]}, {:supervisor, :do_start_child_i, 3, [file: 'supervisor.erl', line: 414]}, {:supervisor, :do_start_child, 2, [file: 'supervisor.erl', line: 400]}, {:supervisor, :handle_start_child, 2, [file: 'supervisor.erl', line: 706]}, {:supervisor, :handle_call, 3, [file: 'supervisor.erl', line: 455]}, {:gen_server, :try_handle_call, 4, [file: 'gen_server.erl', line: 1149]}, {:gen_server, :handle_msg, 6, [file: 'gen_server.erl', line: 1178]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 240]}]}}, {:child, :undefined, :disk_log_sup, {:disk_log_sup, :start_link, []}, :permanent, false, 1000, :supervisor, [:disk_log_sup]}}}
    (kernel 8.5.4) disk_log_server.erl:142: :disk_log_server.ensure_started/0
    (kernel 8.5.4) disk_log_server.erl:52: :disk_log_server.open/1
    (stdlib 4.3) ets.erl:815: :ets.tab2file/3
    (mix 1.14.3) lib/mix/compilers/application_tracer.ex:220: Mix.Compilers.ApplicationTracer.write_manifest/1
    (mix 1.14.3) lib/mix/compilers/application_tracer.ex:41: Mix.Compilers.ApplicationTracer.prepare/2
    (mix 1.14.3) lib/mix/compilers/elixir.ex:150: Mix.Compilers.Elixir.compile/7
    (mix 1.14.3) lib/mix/state.ex:15: Mix.State.lock/2
    (mix 1.14.3) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4

I’m wondering if this is some sort of permissions thing? Or if there’s crud from an earlier installation lying around somewhere?

Also note this:

528 $ mix help
** (FunctionClauseError) no function clause matching in Mix.Tasks.Iex.__info__/1    
    
    The following arguments were given to Mix.Tasks.Iex.__info__/1:
    
        # 1
        :attributes
    
    (mix 1.14.3) Mix.Tasks.Iex.__info__/1
    (mix 1.14.3) lib/mix/tasks/help.ex:178: anonymous fn/2 in Mix.Tasks.Help.build_task_doc_list/1
    (elixir 1.14.3) lib/enum.ex:2468: Enum."-reduce/3-lists^foldl/2-0-"/3
    (mix 1.14.3) lib/mix/tasks/help.ex:171: Mix.Tasks.Help.build_doc_list/2
    (mix 1.14.3) lib/mix/tasks/help.ex:50: Mix.Tasks.Help.run/1
    (mix 1.14.3) lib/mix/task.ex:421: anonymous fn/3 in Mix.Task.run_task/4
    (mix 1.14.3) lib/mix/cli.ex:84: Mix.CLI.run_task/2

mix help works outside of the new project directory.


Did this sequence of commands to get the above results.

> rm -rf ~/.mix*
> brew uninstall elixir erlang
> brew install elixir
> elixir --version
Erlang/OTP 25 [erts-13.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit:ns] [dtrace]

Elixir 1.14.3 (compiled with Erlang/OTP 25)
> mix new first
> cd first
> mix test

I don’t see anything weird in my .bashrc, etc. files, and the PATH seems right:

509 $ whereis mix
mix: /usr/local/bin/mix /usr/local/share/man/man1/mix.1
510 $ ls -l /usr/local/bin/mix
lrwxr-xr-x  1 bem  admin  31 Mar 15 13:19 /usr/local/bin/mix@ -> ../Cellar/elixir/1.14.3/bin/mix
3 Likes

Hi Brian, that is puzzling and annoying. My hypothesis is that:-

  1. There’s something messed up with the Brew Elixir formula - it’s bundling a wrong .beam file in or something, but I’ve really no idea.
  2. No-one uses Brew to install Elixir any more so nobody else has noticed.

If you want to run with the crowd, I’d say that most people use Asdf these days, which builds Erlang from source. That said building Erlang can be fiddly: pay close attention to the suggested prerequisites for the Erlang plugin. Also you need to match the Elixir with the Erlang. Eg choose elixir 1.14.3-otp-25 to go with Erlang 25.

4 Likes

I’ve used brew to install and haven’t had issues.

Any dependencies? Did you try running
‘Mix deps.get’ first?

1 Like

I tried mix deps.get. It didn’t make a difference.

However, I installed macports and installing elixir+erlang from there works. I guess I’ll just have to remember what comes from homebrew and what comes from macports.

So I guess it’s some Homebrew ↔ my machine interaction. I could do more digging at the request of [[someone]], but I don’t know who that someone would be or what information would help them.

1 Like

I tried replicating it on my mac to no avail but I do have an intel chip. Sorry I couldn’t be more help!

2 Likes

are you solved the problem?

I’m in the “just use asdf” crowd. It’s super easy and allows control of what version you want to use and where (including Erlang/OTP version).

brew install asdf # The irony, I know.

asdf plugin add erlang https://github.com/asdf-vm/asdf-erlang.git
asdf plugin add elixir https://github.com/asdf-vm/asdf-elixir.git
asdf install erlang 25.3
asdf global erlang 25.3
asdf install elixir 1.14.3-otp-25
asdf global elixir 1.14.3-otp-25

# Ready to go!
iex
4 Likes

thanks, i installed asdf and their plugins. I can open iex and write code, but i have problem after start project

That’s not very concrete, please post what error are you getting.

1 Like

On my m1 Mac, the brew install worked, but I last updated elixir 17 days ago and started a new project, a week before @marick. The main difference I see is that I’m running a later version of MacOs, 13.2.1.

MacOs version: 13.2.1

$ whereis mix
mix: /opt/homebrew/bin/mix /opt/homebrew/share/man/man1/mix.1
Erlang/OTP 25 [erts-13.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

$ elixir --version
Erlang/OTP 25 [erts-13.1.4] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [jit] [dtrace]

Elixir 1.14.3 (compiled with Erlang/OTP 25)


Elixir 1.14.3 (compiled with Erlang/OTP 25)
$ brew info elixir
==> elixir: stable 1.14.3 (bottled), HEAD
Functional metaprogramming aware language built on Erlang VM
https://elixir-lang.org/
/opt/homebrew/Cellar/elixir/1.14.3 (442 files, 6.7MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-02-05 at 07:44:14
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/elixir.rb
License: Apache-2.0
==> Dependencies
Required: erlang ✘
==> Options
--HEAD
	Install HEAD version
==> Analytics
install: 139 (30 days), 18,982 (90 days), 97,067 (365 days)
install-on-request: 139 (30 days), 18,886 (90 days), 96,569 (365 days)
build-error: 0 (30 days)

I guess ‘asdf’ is next, but I am not using that for anything else.

asdf solution won’t compile erlang 25.3 on M1 so far, and brew gives the error above. Anyone on M1 had success with previous versions?

Tried this solution:

still not building
brew build from source has the same issue: erlang: Fix issue of openssl version by zacky1972 · Pull Request #126993 · Homebrew/homebrew-core · GitHub

1 Like

Ok I seem to have made progress.

bloody brew. On M1+ macs, it looks like legacy Brew x86 in rosetta mode causes the issues and installing x86 versions of everything which confuses the erlang and elixir install.

Replacing (or removing and replacing) homebrew so it installs the arm64 version causes pulled repos to be native installs and I can mix test with no issue on a new project.

2 Likes

Aha. Thanks for sharing this Kushalj. I kind of feel this might be the reason why this is happening.

I’m running into the same problem as marick. I installed Elixir using Brew on a Mac with M1 chip. I will try other approaches.