zsh: segmentation fault elixir -v

So I am trying to run elixir on a M1 mac through rosetta, yet I got the following error when I am checking for the version. I have checked this thread, but still it didn’t help: Segmentation fault after update elixir and erlang

zsh: segmentation fault  elixir -v

But somehow it is working correctly, when I just run elixir

❯ elixir
Usage: .elixir-wrapped [options] [.exs file] [data]

## General options

  -e "COMMAND"                 Evaluates the given command (*)
  -h, --help                   Prints this message and exits
  -r "FILE"                    Requires the given files/patterns (*)
  -S SCRIPT                    Finds and executes the given script in $PATH
  -pr "FILE"                   Requires the given files/patterns in parallel (*)
  -pa "PATH"                   Prepends the given path to Erlang code path (*)
  -pz "PATH"                   Appends the given path to Erlang code path (*)
  -v, --version                Prints Elixir version and exits

  --app APP                    Starts the given app and its dependencies (*)
  --erl "SWITCHES"             Switches to be passed down to Erlang (*)
  --eval "COMMAND"             Evaluates the given command, same as -e (*)
  --logger-otp-reports BOOL    Enables or disables OTP reporting
  --logger-sasl-reports BOOL   Enables or disables SASL reporting
  --no-halt                    Does not halt the Erlang VM after execution
  --werl                       Uses Erlang's Windows shell GUI (Windows only)

Options given after the .exs file or -- are passed down to the executed code.
Options can be passed to the Erlang runtime using $ELIXIR_ERL_OPTIONS or --erl.

## Distribution options

The following options are related to node distribution.

  --cookie COOKIE              Sets a cookie for this distributed node
  --hidden                     Makes a hidden node
  --name NAME                  Makes and assigns a name to the distributed node
  --rpc-eval NODE "COMMAND"    Evaluates the given command on the given remote node (*)
  --sname NAME                 Makes and assigns a short name to the distributed node

## Release options

The following options are generally used under releases.

  --boot "FILE"                Uses the given FILE.boot to start the system
  --boot-var VAR "VALUE"       Makes $VAR available as VALUE to FILE.boot (*)
  --erl-config "FILE"          Loads configuration in FILE.config written in Erlang (*)
  --pipe-to "PIPEDIR" "LOGDIR" Starts the Erlang VM as a named PIPEDIR and LOGDIR
  --vm-args "FILE"             Passes the contents in file as arguments to the VM

--pipe-to starts Elixir detached from console (Unix-like only).
It will attempt to create PIPEDIR and LOGDIR if they don't exist.
See run_erl to learn more. To reattach, run: to_erl PIPEDIR.

** Options marked with (*) can be given more than once.

I install elixir through nix instead of homebrew, and this is my shell.nix:

{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell { buildInputs = with pkgs; [ elixir_1_11 nodejs-16_x ]; }

And the version of my Mac is Big Sur 11.4. How can I solve this issue?

Make sure you are not running under Rosetta emulation and actually running a native Erlang.

As for Nix, I have no experience there.

I’m not a mac user, therefore I can only barely help…

I’d expect your shell.nix to properly work. Though as Dimitar says… You probably need to use a natively built erlang. From all I’ve heard on other occasions, it seems to not like beeing run in rosetta emulation.

I am running Elixir and Erlang on M1 fine.

But I’ve used asdf to install them, and they’re running in native mode, so I don’t know how it would work with Rosetta.

Maybe try installing installing asdf with nix and use asdf to install Erlang and Elixir.

asdf actually compiles Erlang, so it would be native. It does not compile Elixir, but I’m pretty sure it installs native version too.

I gave up on this one and decided to use my x86 linux to run elixir and do the work. I have installed nix through rosetta previously, I am not sure if I need to remove the existing installation and install it again without rosetta, yet it doesn’t support ARM right now.

I have tried to use a non-rosetta, arm native shell to install elixir and erlang, yet no dice.