BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1)

I tried a lot of things from online forums. But never worked. Installed Xcode to see if it works. But it doesn't.

At first, there was an issue with the C executables at the time of the OpenSSL installation. But later, I found from here, the error occurred because of Anaconda installation. So I uninstalled anaconda and tried to install again.

But now it is throwing a different error.

➜ ~ rbenv install 2.4.0 Downloading openssl-1.1.0j.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/31bec6c203ce1a8e93d5994f4ed304c63ccf07676118b6634edded12ad1b3246 Installing openssl-1.1.0j... Installed openssl-1.1.0j to /Users/akashpinnaka/.rbenv/versions/2.4.0

Downloading ruby-2.4.0.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2 Installing ruby-2.4.0... ruby-build: using readline from homebrew

BUILD FAILED (OS X 10.15.1 using ruby-build 20191124)

Inspect or clean up the working tree at /var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.0Fmlfl Results logged to /var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.log

Last 10 log lines: num2int.c:64:5: note: to match this '(' sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num)); ^ /usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf' builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS) ^ 190 warnings and 2 errors generated. make[2]: * [num2int.o] Error 1 make1: * [ext/-test-/num2int/all] Error 2 make: *** [build-ext] Error 2

Did anyone face this problem before? Any help would be greatly appreciated.

UPDATE

Adding the last few lines in the logfile. Most of them look like errors in C lang

/usr/local/include/stdlib.h:354:36: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
/usr/local/include/stdlib.h:354:36: note: insert '_Nullable' if the pointer may be null
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
                                            _Nullable 
/usr/local/include/stdlib.h:354:36: note: insert '_Nonnull' if the pointer should never be null
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
                                            _Nonnull 
/usr/local/include/stdlib.h:356:13: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
/usr/local/include/stdlib.h:356:13: note: insert '_Nullable' if the pointer may be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nullable 
/usr/local/include/stdlib.h:356:13: note: insert '_Nonnull' if the pointer should never be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nonnull 
num2int.c:56:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
                    ^
num2int.c:56:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
    ^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                          ^
num2int.c:64:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
                    ^
num2int.c:64:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
    ^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                          ^
190 warnings and 2 errors generated.
make[2]: *** [num2int.o] Error 1
make[1]: *** [ext/-test-/num2int/all] Error 2
make: *** [build-ext] Error 2

Here is the pate bin for the detailed errors: https://pastebin.com/wzLGzvC5

EDIT:

$ which clang

/usr/bin/clang

$ brew ls

adns        gnutls      libksba     openssl     ruby
autoconf    icu4c       libtasn1    openssl@1.1 ruby-build
automake    libassuan   libtool     p11-kit     sqlite
awk     libevent    libunistring    pinentry    unbound
coreutils   libffi      libusb      pkg-config  zlib
gettext     libgcrypt   libyaml     postgresql
gmp     libgpg-error    nettle      rbenv
gnupg       libidn2     npth        readline

$ brew doctor

Your system is ready to brew.

After I deleted the files suggested by brew doctor

Few lines from

$ ls -la /usr/local/include

total 0
drwxrwxr-x  270 akashpinnaka  admin  8640 Dec 24 11:30 .
drwxr-xr-x   18 root          wheel   576 Dec  5 11:15 ..
-rw-r--r--    1 akashpinnaka  admin     0 Dec  5 10:11 .keepme
lrwxr-xr-x    1 root          admin    85 Dec  5 11:21 AppleTextureEncoder.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AppleTextureEncoder.h
lrwxr-xr-x    1 root          admin    78 Dec  5 11:21 AssertMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AssertMacros.h
lrwxr-xr-x    1 root          admin    78 Dec  5 11:21 Availability.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h
lrwxr-xr-x    1 root          admin    86 Dec  5 11:21 AvailabilityInternal.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h
lrwxr-xr-x    1 root          admin    84 Dec  5 11:21 AvailabilityMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h
lrwxr-xr-x    1 root          admin    86 Dec  5 11:21 AvailabilityVersions.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h

Unable to install Ruby 2.5.1 on macOS 10.14 Mojave � Issue #1327 , When running the following: rbenv install 2.5.1 The install fails with the homebrew BUILD FAILED (OS X 10.14 using ruby-build 20180822)� Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Jobs Programming and related technical career opportunities

I was facing a similar issue and can recommend the approach below that's related to binutils needing to be uninstalled first. What worked for me:

brew uninstall binutils
# Uninstalling /usr/local/Cellar/binutils/2.33.1... (134 files, 167.6MB)

rbenv install 2.6.5 && rbenv local 2.6.5 ;
# Downloading openssl-1.1.1d.tar.gz...
# -> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
# Installing openssl-1.1.1d...
# Installed openssl-1.1.1d to /Users/auser/.rbenv/versions/2.6.5

# Downloading ruby-2.6.5.tar.bz2...
# -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
# Installing ruby-2.6.5...
# ruby-build: using readline from homebrew
# Installed ruby-2.6.5 to /Users/auser/.rbenv/versions/2.6.5

Prior to this the I was also getting a number of varying messages in ruby-build.log - with the last being:

# ld: symbol(s) not found for architecture x86_64

A number of other steps that I took as part of my homebrew stepup (prior to uninstall) included:

brew install perl ruby rbenv
# // UPDATE PATHs with suggestions made by brew during install
which awk perl
# /usr/local/bin/awk
# /usr/local/bin/perl
# ^^^ IN SHORT ALL PATHs should be with /usr/local/opt OR /usr/local/bin

You can re-install binutils again after as needed and remember to repeat the uninstallation with any future rbenv install version(s) that you're likely to re-execute (note to self).

PS - tested on macOS Catalina 10.15.3 (19D76) successfully installing both 2.4.0 & 2.6.5

Cannot install Ruby versions < 2.4 because of openssl@1.1 , It seems the most recent change to ruby-build 20191002 homebrew be a great help to anyone using rbenv to install a <2.4.0 on mac. BUILD FAILED (OS X 10.15.3 using ruby-build 20200218) Inspect or I have 10.15.1 & CLTools 11.2. 0.0.1.1571444319 and the install for 2.3.8 completed normally. Dismiss Join GitHub today. GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.

Can you try to run these commands:

brew unlink gawk
brew reinstall awk
awk

before running rbenv install 2.4.0

ruby-build, BUILD FAILED (OS X 10.15.5 using ruby-build 20200520) Inspect or clean up rbenv install of any ruby version fails on OS X 10.10.4 using latest rbenv and Ruby 2.7.0 installation fails on Catalina. I just set up a new mac, and now RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 2.6.5 is failing with this error: Stack Overflow Public questions and answers; Teams Private questions and answers for your team; Enterprise Private self-hosted questions and answers for your enterprise; Talent Hire technical talent

Meme Overflow on Twitter: "BUILD FAILED (OS X 10.15.1 using ruby , Created 8 years ago in rbenv/ruby-build with 52 comments. I'd guess that most ruby-build installations are on one of two platforms—Mac OS X x86_64 or rbenv install of any ruby version fails on OS X 10.10.4 using latest rbenv and BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) Inspect or clean up the � BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1) 3 Why does brew say that nodejs is installed?

rbenv, Embed Tweet. BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1)�

ERROR EN LA CONSTRUCCI�N (OS X 10.15.1 con Ruby-build , BUILD FAILED (LinuxMint 19.3 using ruby-build 20200727) the lines helped fix my issue installing ruby, for installing Jekyll with Apple's new ZSH shell. 1 commit in eregon/ruby-build/tree/graalvm-macos rbenv/ruby-build/tree/master.

Comments
  • What's in the logfile? Please add the content to the question.
  • @Casper, logfile has 20 million lines, I can post the last few lines
  • Added few errors.
  • @Casper Added pastebin with more detailed errors
  • Gcc would be much more preferable as compiler I think. Not an OSX expert but something is screwed up on catalina. Did you try these suggestions? github.com/rbenv/ruby-build/issues/1361
  • Found something really interesting… Found this 7 years old gist with the very same error, at the same line in the same file (except that it is in /usr/include/secure, not local): gist.github.com/mitchty/4187027. This makes me think that you might have a copy under /src/local/include/ of some very old header files from Apple… Could it be that you still have some brew's apple-gcc* formula installed?
  • I think the second "mv" command should copy the "secure" dir back to its original place, but doesn’t.
  • Indeed... Fixed!
  • Thanks for responding @jwatkins. I updated the question with the details you asked
  • You save my life @jwatkins. My problem was a symlink on /usr/local/include after a move out this folder. All works fine. Thank you
  • Tried it. Still the same error. When I brew unlink gawk, it says Error: No such keg: /usr/local/Cellar/gawk. Thanks for responding
  • Same here - does not work (Error: No such keg: /usr/local/Cellar/gawk)
  • Maybe issue is with your local brew installations can you please try this fix: stackoverflow.com/questions/28225045/… @iKK