Excal issue on M1 macOS

Hi folks,

I got a Mac Mini on an M1 chip for work.
Because of an issue with :excal library, we decided to use Docker for the dev env.
Docker is good and it just works.

But Apple promises that with Rosetta 2, everything will run smoothly as previously.

After many manipulations like these:

echo 'alias rosetta="arch -x86_64 zsh"' >> ~/.zshrc

cd /usr/local
sudo mkdir homebrew
sudo chgrp admin homebrew
sudo chmod g+rwx homebrew
curl -L https://github.com/Homebrew/brew/tarball/master | tar xz --strip 1 -C homebrew

# in zshrc
if [ "$(sysctl -n sysctl.proc_translated)" = "1" ]; then
    local brew_path="/usr/local/homebrew/bin"
else
    local brew_path="/opt/homebrew/bin"
fi
export PATH="${brew_path}:${PATH}"

# to be sure my shell is under rosetta or not
echo 'alias is_rosetta="echo $(sysctl -n sysctl.proc_translated)"' >> ~/.zshrc

# install some tools
brew install gcc make libical

Everything is installed, I mix deps.get and then run iex -S mix…

I got this:

==> excal
mkdir -p priv/recurrence
cc -O3 -Wall -I/Users/nitram/.asdf/installs/erlang/23.3.4.4/erts-11.2.2.3/include -fPIC -shared -o priv/recurrence/iterator.so src/recurrence/iterator.c -lical -dynamiclib -undefined dynamic_lookup
src/recurrence/iterator.c:2:10: fatal error: 'libical/ical.h' file not found
#include "libical/ical.h"
         ^~~~~~~~~~~~~~~~
1 error generated.
make: *** [priv/recurrence/iterator.so] Error 1
could not compile dependency :excal, "mix compile" failed. You can recompile this dependency with "mix deps.compile excal", update it with "mix deps.update excal" or clean it with "mix deps.clean excal"
==> tuv2_back
** (Mix) Could not compile with "make" (exit status: 2).
You need to have gcc and make installed. Try running the
commands "gcc --version" and / or "make --version". If these programs
are not installed, you will be prompted to install them.

I can’t find anything related to this issue, any hints ?

Thanks!

1 Like

I don’t know much about macOS but here are some things you might want to check, apologies if you already did.

The problem is that make can’t find the header files for libical.

Seems that with this Rosetta compat mode you launch a shell inside your current shell. Did you install the dependencies while on this Rosetta compat shell? So you need to use homebrew with rosetta, that will change the brew_path to /opt/homebrew/bin. I’ve found this blog and looking at your code wouldn’t the brew_path be switched ? Wouldn’t be like

if [ "$(sysctl -n sysctl.proc_translated)" = "1" ]; then
   # with rosetta
    local brew_path="/opt/homebrew/bin"
else
  # not with rosetta
   local brew_path="/usr/local/homebrew/bin"
fi
export PATH="${brew_path}:${PATH}"

The other point is that I would check if the mix deps.get and iex -S mix are running under rosetta too, so they pickup the correct PATH

2 Likes

Here are other problems/solutions while running Erlang on M1

1 Like

I did everything inside a Rosetta shell if I can say.
The /opt/homebrew/bin is for arm64 arch so it’s not inverted. The proc_translated is on 0 when you are running a non Rosetta shell.

That’s why it’s strange. Everything was done under a Rosetta shell with the correct config.
And still got the problem which is confusing.

Indeed! I’ve checked this topic before asking my boss to buy me an M1 Mac.
Seems it was not enough and we should have double check the deps :sweat_smile:

You initially posted you’re doing docker, so I’m curious why you’re doing all this stuff in your local shell?

Because of two reasons:

  • Docker consumes a lot of RAM
  • Apple told us that with Rosetta, we could run anything like on x86

TBH if Docker uses less RAM, I wouldn’t be looking for running anything with Rosetta.
Definitely the main reason is Docker memory consumption.

Try adding these to your profile:

export LDFLAGS="-L/opt/homebrew/include"
export C_INCLUDE_PATH=/opt/homebrew/include
export CPLUS_INCLUDE_PATH=/opt/homebrew/include
export LIBRARY_PATH=/opt/homebrew/lib