Installing specific crystal version with anyenv [Help]

Hello kind people of crystal I come as a humble dev whos lost countless hours debugging this issue…

Issue: crystal fails to run from a particular .git directory that has my service

I have a crystal service that I need to do something in but I am hit with this error:

constraints: project is locked to version 0.33 ( I know… but please dont yell)

Error: execution of command failed with code: 1: cc "${@}" -o '/Users/myUserWoo/.cache/crystal/crystal-run-sam.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 /Users/myUserWoo/.anyenv/envs/crenv/versions/0.33.0/embedded/lib/libgc.a -lpthread /Users/myUserWoo/.anyenv/envs/crenv/versions/0.33.0/src/ext/libcrystal.a -levent -liconv -ldl -L/Users/myUserWoo/.anyenv/envs/crenv/versions/0.33.0/embedded/lib -L/usr/lib -L/usr/local/lib

make: *** [db.migrate] Error 1

linker error.


My Crystal installation process:

$: brew install anyenv

then install crenv as such anyenv install crenv

then install specified crystal version

crenv install 0.33.0

  • set this version both locally and globally

❯ crystal --version

Crystal 0.33.0 (2020-02-14)

LLVM: 6.0.1

Default target: x86_64-apple-macosx


my crystal env then looks like:

CRYSTAL_CACHE_DIR="/Users/myUserWoo/.cache/crystal"

CRYSTAL_PATH="/Users/myUserWoo/.anyenv/envs/crenv/versions/0.33.0/share/crystal/src:/Users/manuelsaleta/.anyenv/envs/crenv/versions/0.33.0/src:libs:lib"

CRYSTAL_VERSION=“0.33.0”

CRYSTAL_LIBRARY_PATH="/Users/myUserWoo/.anyenv/envs/crenv/versions/0.33.0/embedded/lib"


MacOS Info:

BigSur 11.6 (Intel based cpu)


Some exports ive added to my .shellrc file

export PKG_CONFIG_PATH="/usr/local/opt/openssl@3/lib/pkgconfig"

export PATH="/usr/local/opt/openssl@3/bin:$PATH"

export LDFLAGS="-L/usr/local/opt/openssl@3/lib"

export CPPFLAGS="-I/usr/local/opt/openssl@3/include"

export PATH="/usr/local/opt/llvm@11/bin:$PATH"

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


Im new to MacOS and Crystal coming from a .net background this has been a bit challenging…

ive gone through many of the github threads searching for an answer

Something to note:

I can run and compile crystal files outside of the project’s directory


Mods if this is not the right place kindly let me know thank you.

Any help is appreciated D: thank you

Is there anymore output above the Error: execution of command failed with code: 1 line?

I noticed you seem to be using openssl3. Might be related to Support OpenSSL 3.0 · Issue #11231 · crystal-lang/crystal · GitHub?

Hello Blacksmoke16 - thanks for the link; on the error bit Here is more info:
The undefined keys

Undefined symbols for architecture x86_64:
“_EVP_MD_size”, referenced from:
_*OpenSSL::Digest#digest_size:Int32 in O-penS-S-L-5858D-igest.o
“_EVP_PKEY_size”, referenced from:
_*OpenSSL::PKey::RSA@OpenSSL::PKey::PKey#max_encrypt_size:Int32 in O-penS-S-L-5858P-K-ey5858R-S-A-.o
ld: symbol(s) not found for architecture x86_64
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/manuelsaleta/.cache/crystal/crystal-run-sam.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 /Users/anywhowoo/.anyenv/envs/crenv/versions/0.33.0/embedded/lib/libgc.a -lpthread /Users/anywhowoo/.anyenv/envs/crenv/versions/0.33.0/src/ext/libcrystal.a -levent -liconv -ldl -L/Users/anywhowoo/.anyenv/envs/crenv/versions/0.33.0/embedded/lib -L/usr/lib -L/usr/local/lib
make: *** [db.migrate] Error 1

Okay, yea. I’d maybe just try downgrading to openssl1. That’s prob the only workaround until that issue is resolved.

@Blacksmoke16 - from your comment I took a second to look at my installed packages.

UPDATE: I was able to get crystal to compile correctly by uninstalling openssl@3 and updating my .shell file to export openssl@1.1 instead as such:

export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

export PATH="/usr/local/opt/llvm@11/bin:$PATH"

export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/opt/openssl1.1/lib/pkgconfig

export PATH="/usr/local/opt/llvm/bin:$PATH"

Thank you dude!!!