Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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    [email protected] 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
like image 802
Akash Pinnaka Avatar asked Dec 05 '19 07:12

Akash Pinnaka


1 Answers

First, let trim your log to the significant part:

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__)

Basically, this says that there was an error while expanding a macro to some line in file num2int.c. So, where is does that macro come from? The log says that the macro was defined in file /usr/local/include/secure/_stdio.h.

This file correspond to a locally installed package, most probably added through brew (it could also have been installed by some application installed with a package installer, but this appears less probable). I have not found yet to which package that file belongs (don't have it on my computer and havn't found any reference to it on Google), but _stdio.h files are rather exceptionnal, so I believe that it might be related to brew's private GCC. Yet, ruby-build (when executed though rb-env install) prefer to use XCode's clang compiler, which might not support some syntax extension supported by brew's GCC.

In short, you end up loading in Apple's clang some local include file that use some syntax thaat is not compatible with that compiler.

What to do now?

You must determine if the /usr/local/include/secure/ directory is actually useful. Maybe, this is related to a program that you no longer use… I can't tell you exactly what to do about this, but here are some ideas:

  • Check if either secure or secure/_stdio.h is a symlink (i.e.: ls -l /usr/local/include/secure/). If they have been installed by brew, they should point to somewhere under ../Cellar/<package-name>. If there are, maybe you could consider uninstalling that package…

  • Run brew doctor and check for "Unexpected header files".

Ideally, you want to end up deleting that directory… If you are not certain either it is a good idea, then you may consider moving it temporarilly out of the include directory, for example by doing the following:

mkdir /usr/local/include.disabled
mv /usr/local/include/secure /usr/local/include.disabled/secure

# Compile ruby

mv /usr/local/include.disabled/secure /usr/local/include/secure
rm -rf /usr/local/include.disabled

If none of this works, please post the output of the following commands to a pastebin:

which clang

brew doctor

brew ls

ls -la /usr/local/include

How to move all OSX SDK include files out of local/include

I think the following command should be enough to move all include files pointing to the OSX SDK out of the /usr/local/include directory (my uncertainty here is related to either sub-directories were themselves symlinked, or if it is the content of these subdirectories that is symlinke… I assumed the first, and this oneliner script will miss directories if they are of the second type).

mkdir -p /usr/local/include.disabled/
find /usr/local/include/ -depth 1 -lname '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/*' -exec mv '{}' /usr/local/include.disabled/ ';'

Run these commands, then execute ls -la /usr/local/include again… There should be much less content in it. Do you still have a secure directory there?

And most importanly, can you now get through your original build?

like image 198
jwatkins Avatar answered Sep 30 '22 00:09

jwatkins