1

I just migrated OS X from my old MBP to the newest one, running on OS X High Sierra. Ruby/RVM looked to be broken. I've tried the following:

  1. Reinstalled XCode
  2. Reinstalled command line tools
  3. Reinstalled RVM
  4. Reinstalled homebrew

Running rvm install 2.3.3 results in the following:

+__rvm_make:0> make -j 1
    CC = gcc
    LD = ld
    LDSHARED = gcc -dynamiclib
    CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens   -fno-common -pipe 
    XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT
    CPPFLAGS = -I/usr/local/opt/openssl/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/readline/include -I/usr/local/opt/libksba/include -I/usr/local/opt/openssl/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I. -I.ext/include/x86_64-darwin17 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/libyaml/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/openssl/lib -install_name /Users/rui/.rvm/rubies/ruby-2.3.3/lib/libruby.2.3.0.dylib -current_version 2.3.0 -compatibility_version 2.3.3  -fstack-protector -Wl,-u,_objc_msgSend -framework CoreFoundation  -fstack-protector -Wl,-u,_objc_msgSend -framework CoreFoundation  
    SOLIBS = -lpthread -ldl -lobjc 
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
translating probes probes.d
. ./vm_opts.h
compiling main.c
In file included from main.c:13:
In file included from ./include/ruby.h:33:
./include/ruby/ruby.h:1563:9: error: use of undeclared identifier 'LONG_MAX'
    if (RB_FIXABLE(v))
        ^
./include/ruby/ruby.h:385:24: note: expanded from macro 'RB_FIXABLE'
#define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
                       ^
./include/ruby/ruby.h:383:33: note: expanded from macro 'RB_POSFIXABLE'
#define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
                                ^
./include/ruby/ruby.h:251:26: note: expanded from macro 'RUBY_FIXNUM_MAX'
#define RUBY_FIXNUM_MAX (LONG_MAX>>1)
                         ^
./include/ruby/ruby.h:1563:9: error: use of undeclared identifier 'LONG_MIN'
./include/ruby/ruby.h:385:44: note: expanded from macro 'RB_FIXABLE'
#define RB_FIXABLE(f) (RB_POSFIXABLE(f) && RB_NEGFIXABLE(f))
                                           ^
./include/ruby/ruby.h:384:34: note: expanded from macro 'RB_NEGFIXABLE'
#define RB_NEGFIXABLE(f) ((f) >= RUBY_FIXNUM_MIN)
                                 ^
./include/ruby/ruby.h:252:38: note: expanded from macro 'RUBY_FIXNUM_MIN'
#define RUBY_FIXNUM_MIN RSHIFT((long)LONG_MIN,1)
                                     ^
./include/ruby/ruby.h:1573:9: error: use of undeclared identifier 'LONG_MAX'
    if (RB_POSFIXABLE(v))
        ^
./include/ruby/ruby.h:383:33: note: expanded from macro 'RB_POSFIXABLE'
#define RB_POSFIXABLE(f) ((f) < RUBY_FIXNUM_MAX+1)
                                ^
./include/ruby/ruby.h:251:26: note: expanded from macro 'RUBY_FIXNUM_MAX'
#define RUBY_FIXNUM_MAX (LONG_MAX>>1)
                         ^
In file included from main.c:13:
In file included from ./include/ruby.h:33:
In file included from ./include/ruby/ruby.h:1988:
In file included from ./include/ruby/intern.h:35:
./include/ruby/st.h:85:30: error: use of undeclared identifier 'CHAR_BIT'
    st_index_t num_entries : ST_INDEX_BITS - 1;
                             ^
./include/ruby/st.h:60:45: note: expanded from macro 'ST_INDEX_BITS'
#define ST_INDEX_BITS (sizeof(st_index_t) * CHAR_BIT)
                                            ^
4 errors generated.
make: *** [main.o] Error 1
+__rvm_make:0> return 2
Rui Jiang
  • 1,662
  • 1
  • 15
  • 25
  • Try Ruby 2.3.5? This seems like a bug (missing include for `limits.h`). You could perhaps fix it by adding `#include ` at the top of `ruby.h`. But that's just a guess. Better try 2.3.5 instead and see if it's fixed there. – Casper Dec 02 '17 at 18:54
  • Thanks for the suggestion. It seems to fail on latest stable Ruby (2.4.1) so I don't think that's it. It just seems like my compiler is failing to find the C standard library headers. – Rui Jiang Dec 03 '17 at 03:21

1 Answers1

2

Turns out that GCC was looking at the wrong directories for standard headers. The solution is the same as the one posted here: Broken c++ std libraries on macOS High Sierra 10.13

Rui Jiang
  • 1,662
  • 1
  • 15
  • 25