Apple Silicon Segmentation Fault, Bus Error, ... while compiling phoenix 1.7.2

Hi There,
I am suffering. I try to get elixir & phoenix running on my M1 Macbook. And I really tried it in a lot of different ways.

It always ends with a segfault or bus error when installing phoenix:

mix archive.install hex phx_new
Resolving Hex dependencies…
Resolution completed in 0.019s
New:
phx_new 1.7.2

  • Getting phx_new (Hex package)
    All dependencies are up to date
    Compiling 11 files (.ex)
    [1] 89999 bus error mix archive.install hex phx_new

or

mix archive.install hex phx_new
Resolving Hex dependencies…
Resolution completed in 0.017s
New:
phx_new 1.7.2

  • Getting phx_new (Hex package)
    All dependencies are up to date
    Compiling 11 files (.ex)
    [1] 90027 segmentation fault mix archive.install hex phx_new

Things I already considered:

  • Preventing the Terminal to use Rosetta. uname -m → arm64
  • Doing the installation process with homebrew (including re-installing asdf, and homebrew)
  • Downgrading Phoenix and Elixier/Erlang to previous versions
  • Interestingly I do not get any segmentation fault when using iex
  • My main path is to try to install the latest stable version Phoenix 1.7.2 with
  • 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.4 (compiled with Erlang/OTP 25)

Any Ideas?

Hi @rhinerunner welcome, how did you install Erlang? PHoenix does not compile any native code so if you’re having segfaults then something is broken with the underlying erlang install.

1 Like

Hi @benwilson512,
thanks for focusing my attention to this. I installed it via asdf. Now I discarded it and built it from source via brew. (after the regular install didn’t work)
‘brew install --build-from-source erlang’ (25.3.2)
and then
elixir on top of that.

phx_new 1.7.2 is still failing with segmentation faults.

Ensure that when you installed erlang from source you have most of OTP libraries installed, ideally your list of not installed libraries should be:

  1. wx - you need wxwidgets installed;
  2. JInterface - you have to have java installed for this library to compile;
  3. odbc - never used, don’t think it is used anywhere in elixir.

The reason is that if for example you are missing OpenSSL, you won’t be able to compile crypto package from OTP and then you won’t be able to use phoenix because it is using crypto package.

Hi @D4no0,

from my point of view I’am already past that point, e.g. I fixed the issues with openssl crypto library during build time.

I am still at:
~mix archive.install hex phx_new
Resolving Hex dependencies…
Resolution completed in 0.018s

New:
phx_new 1.7.2

  • Getting phx_new (Hex package)
    All dependencies are up to date

Compiling 11 files (.ex)
[1] 31538 segmentation fault mix archive.install hex phx_new

Can I somehow turn on debug/verbose mode for the compile step?

1 Like

It’s the Erlang ODBC interface. The older SQL Server Ecto provider (mssqlex) uses it and if you need old school access to corporate data repositories you will probably need it.

1 Like

I’m successfully running Elixir 1.14.3 using asdf, and the same version of Erlang as you. Mac is M1 first gen MacBook Pro, running Ventura 13.3.1 a. I just tested installing the latest Phoenix and it was fine. I do remember fiddling around to get a stable set up when I first started working on my M1 Mac - I can’t recall where I got the recipe, but this article looks familiar:

And then used asdf to bring it to current versions.

The other thing - you need to make sure everything is built for ARM rather than rosetta-enabled - turn Rosetta off for the terminal and you may need to reinstall Homebrew. See Segmentation fault after update elixir and erlang - #10 by bjorng

3 Likes

Ok - Problem solved … The problem was, that even if Terminal was running under arm64 (uname -m), homebrew found its way to run under x86.

I veryfied it via
$ brew config
which said

macOS: 13.3.1-x86_64
Xcode: N/A
Rosetta 2: true

after force switching to arm-brew thanks to this site

$ eval “$(/opt/homebrew/bin/brew shellenv)”

$ brew config
macOS: 13.3.1-arm64
Xcode: N/A
Rosetta 2: false

Then everything went through.
Thanks everyone for helping out.

2 Likes