Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

/usr/local/opt/[email protected]/include/v8.h:98:1: error: unknown type name 'namespace' #457

Closed
ahuigo opened this issue May 18, 2020 · 4 comments

Comments

@ahuigo
Copy link

ahuigo commented May 18, 2020

I failed to install therubyracer. My env is:

Mac osx: Catalina 10.15.2
Ruby:  ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.x86_64-darwin19]
clang version 11.0.3 (clang-1103.0.32.59)

Here is output:

$ sudo gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected] 
....
	ERROR: Failed to build gem native extension.
......
To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1
....

$ cat /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/therubyracer-0.12.3/mkmf.log
--------------------
find_header: checking for v8.h... -------------------- no

"xcrun clang -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -I/usr/local/opt/[email protected]/include -I/usr/local/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wall -g -rdynamic  -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS  -arch x86_64  -c conftest.c"
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
In file included from conftest.c:3:
/usr/local/opt/[email protected]/include/v8.h:98:1: error: unknown type name 'namespace'
namespace v8 {
^
/usr/local/opt/[email protected]/include/v8.h:98:13: error: expected ';' after top level declarator
namespace v8 {
            ^
            ;
2 errors generated.
checked program was:
/* begin */
1: #include "ruby.h"
2: 
3: #include <v8.h>
/* end */

--------------------
$ gsed -n '95,100p' /usr/local/opt/[email protected]/include/v8.h
/**
 * The v8 JavaScript engine.
 */
namespace v8 {

class Context;
@ahuigo
Copy link
Author

ahuigo commented May 18, 2020

Related issue: #455
This error relates the command :

"xcrun clang -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -I/usr/local/opt/[email protected]/include -I/usr/local/opt/[email protected]/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -Wall -g -rdynamic  -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS  -arch x86_64  -c conftest.c"
clang: warning: argument unused during compilation: '-rdynamic' [-Wunused-command-line-argument]
In file included from conftest.c:3:
/usr/local/opt/[email protected]/include/v8.h:98:1: error: unknown type name 'namespace'

@gruntfarm
Copy link

Getting the same error and nothing is helping. Tried the method that involves the --with-v8-dir=/usr/local/opt/[email protected] flag and I'm still getting the same message.

Also set the following options in my .zshrc file
export CXX=clang++
export GYPFLAGS=-Dmac_deployment_target=10.15

@gruntfarm
Copy link

gruntfarm commented Jun 22, 2020

Ok fixed it by installing both v8 & theruby racer with bundler and instead of running bundle config build.libv8 --with-system-v8 which is what every instruction here told me, I ran bundle config build.libv8 --with-cxx=clang++

So the full ~/.bundle/config is

---
BUNDLE_BUILD__LIBV8: "--with-cxx=clang++"
BUNDLE_BUILD__THERUBYRACER: "--with-v8-dir=/usr/local/opt/[email protected]"

You can also maybe add --with-v8-include and --with-v8-lib options to the 2nd line which is what I also had but I don't think those are necessary.

@lloeki
Copy link
Contributor

lloeki commented Dec 4, 2023

Sorry but this gem is unmaintained, so I will close this issue.

We recommend going with mini_racer + libv8-node. If you feel the issue is still relevant to either of those, please open an issue over there!

@lloeki lloeki closed this as completed Dec 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants