Ruby-build: 2.4.x fails to build in macOS 10.12.6 with Xcode 9

Created on 20 Sep 2017  路  15Comments  路  Source: rbenv/ruby-build

I just upgraded to Xcode 9 and also upgraded ruby-build on macOS 10.12.6. I'm trying to install ruby 2.4.2.

Unlike #1119, there is nothing referencing tar in the log lines, and I do not have homebrew tar installed:

compiling ancdata.c
compiling raddrinfo.c
compiling ifaddr.c
linking shared-object socket.bundle
installing default socket libraries
compiling stringio.c
linking shared-object stringio.bundle
compiling strscan.c
linking shared-object strscan.bundle
compiling syslog.c
linking shared-object syslog.bundle
installing default syslog libraries
compiling zlib.c
linking shared-object zlib.bundle
linking ruby
Generating RDoc documentation
dyld: lazy symbol binding failed: Symbol not found: _utimensat
  Referenced from: /private/var/folders/kh/2szdbjbd5239z59zflvcqbf40000gn/T/ruby-build.20170920140005.43977/ruby-2.4.2/./ruby
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _utimensat
  Referenced from: /private/var/folders/kh/2szdbjbd5239z59zflvcqbf40000gn/T/ruby-build.20170920140005.43977/ruby-2.4.2/./ruby
  Expected in: /usr/lib/libSystem.B.dylib

make: *** [rdoc] Abort trap: 6

I get the same error for 2.4.0.

Most helpful comment

I was able to install after running the following:

$ xcode-select --install

All 15 comments

I discovered this relevant section in the logs further up:

compiling eval.c
compiling file.c
compiling gc.c
file.c:2580:13: warning: 'utimensat' is only available on macOS 10.13 or newer [-Wunguarded-availability-new]
        if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
            ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/stat
.h:374:5: note: 'utimensat' has been explicitly marked partial here
int     utimensat(int __fd, const char *__path, const struct timespec __times[2],
        ^
file.c:2580:13: note: enclose 'utimensat' in a __builtin_available check to silence this warning
        if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
            ^~~~~~~~~
compiling hash.c

Thanks for your report. It seems a problem macOS Sierra with Xcode 9. I will investigate this.

I'm also having issues compiling ruby with Xcode 9, but with a different error:

Last 10 log lines:
checking host system type... x86_64-apple-darwin16.7.0
checking target system type... x86_64-apple-darwin16.7.0
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... configure: error: in `/var/folders/wv/1q625ql117500fbrwb24r9ch0000gn/T/ruby-build.20170921111712.9524/ruby-2.4.2':
configure: error: cannot run C compiled programs.

Was all fine with Xcode 8.

I get an almost identical error as @bgentry, but trying to install Ruby 2.3.5. I also have Mac OS X 10.12.6 and Xcode 9.0.

compiling gc.c
compiling hash.c
file.c:2587:13: warning: 'utimensat' is only available on macOS 10.13 or newer [-Wunguarded-availability-new]
        if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
            ^~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/sys/stat.h:374:5: note: 'utimensat' has been explicitly marked partial here
int     utimensat(int __fd, const char *__path, const struct timespec __times[2],
        ^
file.c:2587:13: note: enclose 'utimensat' in a __builtin_available check to silence this warning
        if (utimensat(AT_FDCWD, path, tsp, 0) < 0) {
            ^~~~~~~~~
compiling inits.c
compiling io.c

and

compiling enc/trans/newline.c
linking miniruby
generating encdb.h
dyld: lazy symbol binding failed: Symbol not found: _utimensat
  Referenced from: /private/var/folders/tq/ytgxl0dj5msf4798fb9vlppm0000gn/T/ruby-build.20170921172957.36352/ruby-2.3.5/./miniruby
  Expected in: /usr/lib/libSystem.B.dylib

dyld: Symbol not found: _utimensat
  Referenced from: /private/var/folders/tq/ytgxl0dj5msf4798fb9vlppm0000gn/T/ruby-build.20170921172957.36352/ruby-2.3.5/./miniruby
  Expected in: /usr/lib/libSystem.B.dylib

make: *** [.rbconfig.time] Abort trap: 6

It's a common issue affecting many others with Xcode 9: https://www.google.com/search?q=%22_utimensat%22+xcode9

No specific to Ruby, so perhaps we can wait on an upstream fix.

Does this patch work?

diff --git a/file.c b/file.c
index f42d4f408c..9d7487c649 100644
--- a/file.c
+++ b/file.c
@@ -81,6 +81,10 @@ int flock(int, int);
 # endif
 #endif

+#if defined(__builtin_available) && !__builtin_available(utimensat)
+# undef HAVE_UTIMENSAT
+#endif
+
 #ifdef HAVE_SYS_MKDEV_H
 #include <sys/mkdev.h>
 #endif

I was able to install after running the following:

$ xcode-select --install

I have been banging my head against this problem for half a day, and @huezoaa solution fixed it. Apparently, after you update Xcode, you need to not only accept the license (via the cli), but you need to run that bloody command. Because if you just launch the Xcode app (like I did), it doesn't fully install all the cli bits like says it does.

Ugh, that totally does the trick. I even looked in the Xcode prefs to see if there was a way to install the CLI like there used to be but couldn't find it. Closing this as it doesn't seem like it's ruby-build's problem, thanks @huezoaa :v:

Could the wiki be updated with a note for Xcode 9 to include the additional step? Especially, if you are upgrading. Seeing, that Xcode doesn't give you any feed back the process wasn't completed.

For me the xcode-select trick didn't fix the problem. I found that configure didn't check if the code could be linked. upgrading autoconf did the trick for me.

Just ran into this problem myself. Solved with $ xcode-select --install

Thanks!

Yup $ xcode-select --install fixed it for me too

Perhaps xcode-select --install could form part of a suggested resolutions message, even if it's not run automatically. (It seems to be idempotent.)

OS X 10.14.3
XCode 10.1
Tried to install ruby 2.4.2 with rbenv.

generating makefile exts.mk
*** Following extensions failed to configure:
../.././ext/openssl/extconf.rb:0: Failed to configure openssl. It will not be installed.
*** Fix the problems, then remove these directories and try again if you want.

rbenv install 2.4.2 got it fixed by running following commands : 

 brew reinstall rbenv
 brew reinstall openssl 
 brew reinstall readline

```

Added to ~/.zshrc (my shell)

export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"
export PATH="/usr/local/opt/openssl/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
export PKG_CONFIG_PATH="/usr/local/opt/readline/lib/pkgconfig"

Was this page helpful?
0 / 5 - 0 ratings