> RUBY_CONFIGURE_OPTS="--with-openssl-dir=`brew --prefix openssl` --with-readline-dir=`brew --prefix readline` --with-libyaml-dir=`brew --prefix libyaml`" rbenv install 2.7.1
Downloading ruby-2.7.1.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.1.tar.bz2
Installing ruby-2.7.1...
BUILD FAILED (OS X 10.15.4 using ruby-build 20200401)
Inspect or clean up the working tree at /var/folders/nf/hlsjw5r54rjcnmgdlbvz1d980000gn/T/ruby-build.20200508220318.88289.GSwf36
Results logged to /var/folders/nf/hlsjw5r54rjcnmgdlbvz1d980000gn/T/ruby-build.20200508220318.88289.log
Last 10 log lines:
compiling error.c
compiling eval.c
compiling file.c
file.c:31:10: fatal error: 'CoreFoundation/CFString.h' file not found
#include <CoreFoundation/CFString.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~
file.c:31:10: note: did not find header 'CFString.h' in framework 'CoreFoundation' (loaded from '/System/Library/Frameworks')
1 error generated.
make: *** [file.o] Error 1
make: *** Waiting for unfinished jobs....
I know this might be the problem of macOS rather than rbenv. But I have already linked the headers as below to make sure headers are in the usr/local/include/
sudo ln -s "$(xcrun --show-sdk-path)/usr/include/*" /usr/local/include
sudo ln -s /Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/usr/include/* /usr/local/include/
Is there anything I still missing to compile successfully?
Thanks for the help.
solution found:
put below scripts in .bash_profile or .zshrc. Comment these lines out after ruby is installed or it might influnce original C/C++ environment.
for macOS users, $(xcrun --show-sdk-path)/usr/include/ should be linked as /usr/include with csrutil disabled.
# Setup Compiler paths for readline and openssl
local READLINE_PATH=$(brew --prefix readline)
local OPENSSL_PATH=$(brew --prefix openssl)
export LDFLAGS="-L$READLINE_PATH/lib -L$OPENSSL_PATH/lib"
export CPPFLAGS="-I$READLINE_PATH/include -I$OPENSSL_PATH/include"
export PKG_CONFIG_PATH="$READLINE_PATH/lib/pkgconfig:$OPENSSL_PATH/lib/pkgconfig"
# Use the OpenSSL from Homebrew instead of ruby-build
# Note: the Homebrew version gets updated, the ruby-build version doesn't
export RUBY_CONFIGURE_OPTS="--with-openssl-dir=$OPENSSL_PATH"
# Place [email protected] at the beginning of your PATH (preempt system libs)
export PATH=$OPENSSL_PATH/bin:$PATH
export SDKROOT="$(xcrun --show-sdk-path)"
ref: https://zhile.io/2018/09/26/macOS-10.14-install-sdk-headers.html
Most helpful comment
solution found:
put below scripts in
.bash_profileor.zshrc. Comment these lines out after ruby is installed or it might influnce original C/C++ environment.for macOS users,
$(xcrun --show-sdk-path)/usr/include/should be linked as/usr/includewithcsrutildisabled.ref: https://zhile.io/2018/09/26/macOS-10.14-install-sdk-headers.html