[Noob] Error in brew installation on Mac

#1

Hi,
I’m a 44 year old economist having read and tried some Ruby on Rails a long time ago as well as learnt some C++ in school once. Would like to get into programming again, and Crystal appeals me.

However, my brew install crystal crashed with an error that it couldn’t find package dir (I think…).

I have installed Xcode command line tools, and assume I don’t need the full Xcode?

#2

Hello, welcome to crystal :wink:

Can you give us the full error you get?

#3

Thanks! I am at work (and on Windows) now, but will run it again and paste error this evening.

It didn’t however really crash but there was an error at the end after building LLVM@6 about some dir it didn’t find.

#4

Here´s the output of brew install crystal:

==> Installing dependencies for crystal: llvm@6, pcre and pkg-config
==> Installing crystal dependency: llvm@6
==> Downloading https://homebrew.bintray.com/bottles/llvm@6-6.0.1_1.mojave.bottle.1.tar.gz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/73f50e8d6cc6536b0c0b8c2f785e997af01bffdde43cdca79d1f6d0181b45037--llvm@6-6.0.1_1.mojave.bottle.1.tar.gz
Error: SHA256 mismatch
Expected: bdb6b04ed9307ad89a7bb5058d5b28d1fda5954983f705b971ceb3dce85158b0
  Actual: 56f7e1378ada91fa2a6d65926804bba8372bb6d063f6b8dbf09ef32b045c66f5
 Archive: /Users/thomas1/Library/Caches/Homebrew/downloads/73f50e8d6cc6536b0c0b8c2f785e997af01bffdde43cdca79d1f6d0181b45037--llvm@6-6.0.1_1.mojave.bottle.1.tar.gz
To retry an incomplete download, remove the file above.
Warning: Bottle installation failed: building from source.
==> Downloading https://releases.llvm.org/6.0.1/llvm-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/7cac209bbcafb1e41b0b73a8b4b87f20ac9c6382142420636f0a0beab0a8b35d--llvm-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/cfe-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/a0b4de455939c63eb3c9ee778d4303c4289c41a66d0619e54ae008c6602f69bf--cfe-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/clang-tools-extra-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/7e8c00a4fa00b087b576401933607e227fc41749feef1c5f638c751882c11423--clang-tools-extra-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/openmp-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/9acbc218fbe4cf65d4e86ed611df6efcdab0d4ccc1fad302e581eaf91a9265c0--openmp-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/libcxx-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/9213edc06aa46e6a3a2ea99cd93c67f6f73f7a731973e1f18a3afbe9a0175375--libcxx-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/libunwind-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/772c1b97e40817225a8f78ee4b2d07a6e5cf26c4c1d8ebcc1b3ae2edd9142430--libunwind-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/lld-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/80cf9a655c73f99526607c712cace18cd7e7aea33d1aadb9dbc5ecad0b583600--lld-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/polly-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/d59ff2485c480be5e9df6540941a4878704f60bd26963d304d5c8eb82c8a8b2d--polly-6.0.1.src.tar.xz
==> Downloading https://releases.llvm.org/6.0.1/compiler-rt-6.0.1.src.tar.xz
Already downloaded: /Users/thomas1/Library/Caches/Homebrew/downloads/074fa28ae10d06c5c9701595ac5da7a6abd1a914dca84e48adce7ca22185c303--compiler-rt-6.0.1.src.tar.xz
==> cmake -G Unix Makefiles .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTAL
Last 15 lines from /Users/thomas1/Library/Logs/Homebrew/llvm@6/01.cmake:
  command.


CMake Warning at tools/xcode-toolchain/CMakeLists.txt:60 (message):
  Failed to detect the version of an installed copy of Xcode, falling back to
  highest supported version.  Set XCODE_VERSION to override.


CMake Error at tools/xcode-toolchain/CMakeLists.txt:80 (message):
  Could not identify toolchain dir


-- Configuring incomplete, errors occurred!
See also "/tmp/llvm@6-20190429-36919-jmdzzi/llvm-6.0.1.src/build/CMakeFiles/CMakeOutput.log".
See also "/tmp/llvm@6-20190429-36919-jmdzzi/llvm-6.0.1.src/build/CMakeFiles/CMakeError.log".

READ THIS: https://docs.brew.sh/Troubleshooting

These open issues may also help:
llvm: added lldb https://github.com/Homebrew/homebrew-core/pull/38526
#5

A bit unnerving for a first time installer, but I cleared the homebrew caches and tried again, and then SHA256 matched and it “poured bottles” instead of building every dependancy from sources (which still failed), and, voila, crystal 0.28 available.

BUT, when then running crystal play I get this after the browser has loaded:

Listening on http://127.0.0.1:8080
ld: library not found for -lssl (this usually means you need to install the development package for libssl)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Error: execution of command failed with code: 1: `cc "${@}" -o '/Users/thomas1/.cache/crystal/crystal-run-play-1-1.tmp'  -rdynamic  -lz `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libssl || printf%s '-lssl -lcrypto'` `command -v pkg-config > /dev/null && pkg-config --libs --silence-errors libcrypto || printf %s '-lcrypto'` -lpcre /usr/local/Cellar/crystal/0.28.0/embedded/lib/libgc.a -lpthread /usr/local/Cellar/crystal/0.28.0/src/ext/libcrystal.a -levent -liconv -ldl -L/usr/local/Cellar/crystal/0.28.0/embedded/lib -L/usr/lib -L/usr/local/lib`

I see libevent in there and also reinstalled the xcode commandline tools and ran xcode-select --switch /Library/Developer/CommandLineTools as per the documentation but to no avail. Still the same error…

#6

Hi @thbo, welcome to Crystal!

Since you are using mojave, you are experiencing a known but unresolved issue.

A woraround is to do:

$ brew install openssl
$ export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl/lib/pkgconfig

(or have that line in the ~/.profile or similar)

More information can be found at https://github.com/crystal-lang/crystal/pull/7494 and referenced issues.

1 Like
#7

Thank you very much!

It said openssl was already installed (OSX 10.14.4), but the export of the PKG_CONFIG_PATH seemed to do the trick.

Since Mojave has been out since September 24, 2018 for macs from mid 2012 and newer, I created the pull request https://github.com/crystal-lang/crystal-book/pull/337 for the documentation to include this workaround in the style of the workaround for El Capitan already there.

2 Likes