rubyjs / therubyracer

Embed the V8 Javascript Interpreter into Ruby
1.67k stars 190 forks source link

Unable to install therubyracer on Mac OS Mojave (10.14.1) #452

Closed vipin04 closed 5 years ago

vipin04 commented 5 years ago

While trying to install therubyracer on Mac OS 10.14.1 with command sudo gem install therubyracer

I get following error

/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)

I checked if libv8 is installed with command

gem list -i libv8

It returns true

Complete logs

Fetching: libv8-3.16.14.19.gem (100%) Building native extensions. This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8 /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20190103-54655-1uvigt6.rb extconf.rb creating Makefile Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-building-tests.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch Compiling v8 for x64 Using python 2.7.15 Using compiler: c++ (Apple LLVM version 10.0.0) Unable to find a compiler officially supported by v8. It is recommended to use GCC v4.4 or higher Beginning compilation. This will take some time. Building v8 with env CXX=c++ LINK=c++ /usr/bin/make x64.release ARFLAGS.target=crs werror=no GYP_GENERATORS=make \ build/gyp/gyp --generator-output="out" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ -Dv8_target_arch=x64 \ -S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' CXX(target) /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o warning: include path for stdlibc++ headers not found; pass '-std=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found] In file included from ../src/allocation.cc:33: ../src/utils.h:33:10: fatal error: 'climits' file not found

include

     ^~~~~~~~~

1 warning and 1 error generated. make[1]: [/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1 make: [x64.release] Error 2 /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound) from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:ineach' from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in verify_installation!' from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:ininstall!' from extconf.rb:7:in `

'

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19 for inspection. Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libv8-3.16.14.19/gem_make.out

I tried to use g++ 8.2 compiler to install therubyracer, but it still got failed with following errors sudo gem install therubyracer -- --with-cxx=/usr/local/gcc-8.2/bin/g++-8.2

Building native extensions with: '--with-cxx=/usr/local/gcc-8.2/bin/g++-8.2' This could take a while... ERROR: Error installing therubyracer: ERROR: Failed to build gem native extension.

current directory: /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8 /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20190103-55841-13nxqx5.rb extconf.rb --with-cxx=/usr/local/gcc-8.2/bin/g++-8.2 creating Makefile Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-building-tests.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-werror-on-osx.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/disable-xcode-debugging.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-imply-vfp3-and-armv7.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-use-MAP_NORESERVE-on-freebsd.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/do-not-use-vfp2.patch Applying /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/patches/fPIC-for-static.patch Compiling v8 for x64 Using python 2.7.15 Using compiler: /usr/local/gcc-8.2/bin/g++-8.2 (GCC version 8.2.0) Beginning compilation. This will take some time. Building v8 with env CXX=/usr/local/gcc-8.2/bin/g++-8.2 LINK=/usr/local/gcc-8.2/bin/g++-8.2 /usr/bin/make x64.release ARFLAGS.target=crs werror=no GYP_GENERATORS=make \ build/gyp/gyp --generator-output="out" build/all.gyp \ -Ibuild/standalone.gypi --depth=. \ -Dv8_target_arch=x64 \ -S.x64 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror='' CXX(target) /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o g++-8.2: error: unrecognized command line option ‘-Wnewline-eof’ make[1]: [/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1 make: [x64.release] Error 2 /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound) from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:ineach' from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in verify_installation!' from /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:ininstall!' from extconf.rb:7:in `

'

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/libv8-3.16.14.19 for inspection. Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/libv8-3.16.14.19/gem_make.out

vipin04 commented 5 years ago

I was able to solve this issue by providing clang compiler provided by brew, instead of using clang provided by Xcode command line tools.

brew install llvm

Installed missing headers using by following this blog https://donatstudios.com/MojaveMissingHeaderFiles

Installed the ruby racer with brew's llvm

sudo gem install therubyracer -- --with-cxx=/usr/local/opt/llvm/bin/clang++

if Xcode command line tools are no longer supported by therubyracer, then it should be added to the documentation.

microspino commented 5 years ago

thx @vipin04 this saved me a bunch of hours of struggling. I'm migrating an old ruby project to Mojave. I would like to add that yuo can also configure bundler to use the clang compiler provided by brew with:

bundle config build.therubyracer --with-cxx=/usr/local/opt/llvm/bin/clang++