Crystal on M1 Mac, Big Sur

Hi, trying to install Crystal:

$ brew install crystal
Error: crystal: no bottle available!
You can try to install from source with:
  brew install --build-from-source crystal
Please note building from source is unsupported. You will encounter build
failures with some formulae. If you experience any issues please create pull
requests instead of asking for help on Homebrew's GitHub, Twitter or any other
official channels.

$ brew install --build-from-source crystal
==> Downloading
Already downloaded: /Users/valbaca/Library/Caches/Homebrew/downloads/243054e745fb64c2a2090ee74bd8f5492a73dce467d6eb2121c1de7362522dc3--shards-0.14.1.tar.gz
==> Downloading
Already downloaded: /Users/valbaca/Library/Caches/Homebrew/downloads/21e69d67c3cd1545fe57b82418810e1e827581282b268d1daedf66006865f539--crystal-0.36.1-1-darwin-x86_64.tar.gz
==> Downloading
Already downloaded: /Users/valbaca/Library/Caches/Homebrew/downloads/5e5007f36d96da96dc6b272be7532e052641f5b09706dbeb100477bde10d2944--crystal-1.0.0.tar.gz
==> make deps
==> make crystal release=true FLAGS=--no-debug CRYSTAL_CONFIG_LIBRARY_PATH=
Last 15 lines from /Users/valbaca/Library/Logs/Homebrew/crystal/02.make:
2021-07-08 10:24:43 -0700


Using /opt/homebrew/opt/llvm@11/bin/llvm-config [version=11.1.0]
CRYSTAL_CONFIG_LIBRARY_PATH="" CRYSTAL_CONFIG_BUILD_COMMIT="" SOURCE_DATE_EPOCH="1616422021" ./bin/crystal build --no-debug --release  -o .build/crystal src/compiler/ -D without_openssl -D without_zlib
ld: in '/opt/homebrew/opt/llvm@11/lib/libunwind.dylib', building for macOS-x86_64 but attempting to link with file built for macOS-arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `clang "${@}" -o /private/tmp/crystal-20210708-46787-11la4vt/crystal-1.0.0/.brew_home/.cache/crystal/  -rdynamic -L/opt/homebrew/opt/bdw-gc/lib -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/sqlite/lib -L/opt/homebrew/opt/llvm@11/lib -L/opt/homebrew/lib -L/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/OpenGL.framework/Versions/Current/Libraries -L/private/tmp/crystal-20210708-46787-11la4vt/crystal-1.0.0/boot/embedded/lib -lpcre -lgc -lpthread /private/tmp/crystal-20210708-46787-11la4vt/crystal-1.0.0/src/ext/libcrystal.a -L/opt/homebrew/Cellar/libevent/2.1.12/lib -levent -liconv -ldl`
make: *** [.build/crystal] Error 1

Do not report this issue to Homebrew/brew or Homebrew/core!

Here’s my relevant flags, not sure if they matter:

env | grep FLAG

Looks like this is known:

My arm/M1 brew is installed here:

$ which brew

Step 1. Install x86_64 brew under /usr/local/bin/brew

arch -x86_64 /bin/bash -c "$(curl -fsSL"

Step 2. Create an alias for the x86_64 brew

I added this to my ~/.zshrc

# brew hack for x86
alias ibrew='arch -x86_64 /usr/local/bin/brew'

Step 3. ibrew install crystal

Step 4. Yay!

$ crystal --version
Crystal 1.0.0 (2021-03-22)

LLVM: 11.1.0
Default target: x86_64-apple-macosx

1 Like

I am not sure if you mean just installing the Crystal on M1 Mac or you want some specific environments.

If you just mean to install it and able to run the crystal on your terminal, you should check the pkg file.
You can find the pkg file here: Release 1.0.0 · crystal-lang/crystal · GitHub
(It is actually installed onto the Rosetta 2)

And here is a known discussion: