Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installing therubyracer on Mac OS and Ruby 2.3.0 #266

Closed
justin808 opened this issue Apr 4, 2016 · 17 comments
Closed

Installing therubyracer on Mac OS and Ruby 2.3.0 #266

justin808 opened this issue Apr 4, 2016 · 17 comments

Comments

@justin808
Copy link
Member

If you have the below problem, the solution that worked for me on April 3, 2016 can be found here:

http://stackoverflow.com/a/36388150/1009332

brew tap homebrew/versions
brew install v8-315

gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315

bundle install

Errors that this fixes:

Installing therubyracer 0.12.2 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/justin/.rvm/gems/ruby-2.3.0/gems/therubyracer-0.12.2/ext/v8
/Users/justin/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160403-74333-17ute6e.rb extconf.rb
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/justin/.rvm/rubies/ruby-2.3.0/bin/$(RUBY_BASE_NAME)
    --with-pthreadlib
    --without-pthreadlib
    --with-objclib
    --without-objclib
    --enable-debug
    --disable-debug
    --with-v8-dir
    --without-v8-dir
    --with-v8-include
    --without-v8-include=${v8-dir}/include
    --with-v8-lib
    --without-v8-lib=${v8-dir}/lib
/Users/justin/.rvm/gems/ruby-2.3.0/gems/libv8-3.16.14.13/ext/libv8/location.rb:50:in `configure': You have chosen to use the version of V8 found on your system (Libv8::Location::System::NotFoundError)
and *not* the one that is bundle with the libv8 rubygem. However,
it could not be located. please make sure you have a version of
v8 that is compatible with 3.16.14.13 installed. You may
need to special --with-v8-dir options if it is in a non-standard
location

thanks,
The Mgmt

    from /Users/justin/.rvm/gems/ruby-2.3.0/gems/libv8-3.16.14.13/lib/libv8.rb:7:in `configure_makefile'
    from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/justin/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/therubyracer-0.12.2/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/justin/.rvm/gems/ruby-2.3.0/gems/therubyracer-0.12.2 for inspection.
Results logged to /Users/justin/.rvm/gems/ruby-2.3.0/extensions/x86_64-darwin-15/2.3.0/therubyracer-0.12.2/gem_make.out
@celsian
Copy link

celsian commented Apr 12, 2016

Thanks for this. Saved me a headache.

@bhushangahire
Copy link

Thanks a lot. I tried this before but somehow v8-315 was not downloading. I think they relinked the same :)

@adamjgrant
Copy link

Worked for me as well although I had to change the gem install line to

gem install therubyracer -- --with-v8-dir=/usr/local/opt/[email protected]

Thanks!

@ashleyzhou64
Copy link

ashleyzhou64 commented Mar 11, 2019

MacOS Mojave
install therubyracer version '0.12.2'

brew update
brew install v8
gem install libv8 -v '3.16.14.15' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=#{libv8_path}

on my computer, libv8_path is /usr/local/Cellar/v8/7.2.502.25

@DriesS
Copy link

DriesS commented Apr 5, 2019

MacOS Mojave
install therubyracer version '0.12.2'

brew update
brew install v8
gem install libv8 -v '3.16.14.15' -- --with-system-v8
gem install therubyracer -- --with-v8-dir=#{libv8_path}

on my computer, libv8_path is /usr/local/Cellar/v8/7.2.502.25

In my case I had to use /usr/local/Cellar/v8/7.3.492.25/libexec as libv8_path

@johnpena
Copy link

I still seem to be having this issue even after following all of the steps above:

 gem install therubyracer -- --with-v8-dir=/usr/local/Cellar/v8/7.3.492.27

yields:

Building native extensions with: '--with-v8-dir=/usr/local/Cellar/v8/7.3.492.27'
This could take a while...
ERROR:  Error installing therubyracer:
	ERROR: Failed to build gem native extension.

    current directory: /Users/johnpena/.rvm/gems/ruby-2.3.8/gems/therubyracer-0.12.3/ext/v8
/Users/johnpena/.rvm/rubies/ruby-2.3.8/bin/ruby -r ./siteconf20190410-35503-yir8mp.rb extconf.rb --with-v8-dir=/usr/local/Cellar/v8/7.3.492.27
checking for main() in -lpthread... yes
checking for main() in -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/johnpena/.rvm/rubies/ruby-2.3.8/bin/$(RUBY_BASE_NAME)
	--with-pthreadlib
	--without-pthreadlib
	--with-objclib
	--without-objclib
	--enable-debug
	--disable-debug
	--with-v8-dir
	--with-v8-include
	--without-v8-include=${v8-dir}/include
	--with-v8-lib
	--without-v8-lib=${v8-dir}/lib
/Users/johnpena/.rvm/gems/ruby-2.3.8/gems/libv8-3.16.14.17/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.17 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
	from /Users/johnpena/.rvm/gems/ruby-2.3.8/gems/libv8-3.16.14.17/lib/libv8.rb:7:in `configure_makefile'
	from extconf.rb:32:in `<main>'

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/johnpena/.rvm/gems/ruby-2.3.8/extensions/x86_64-darwin-17/2.3.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/johnpena/.rvm/gems/ruby-2.3.8/gems/therubyracer-0.12.3 for inspection.
Results logged to /Users/johnpena/.rvm/gems/ruby-2.3.8/extensions/x86_64-darwin-17/2.3.0/therubyracer-0.12.3/gem_make.out

I also tried with the libexec path as suggested by the previous comment and it yielded the same result.

@jeffreycastro
Copy link

jeffreycastro commented Apr 16, 2019

This answer https://stackoverflow.com/a/25757171/6186921 worked for me. MacOS Mojave.

gem uninstall libv8
brew install v8
gem install therubyracer
gem install libv8 -v '3.16.14.15' -- --with-system-v8

@ssjod
Copy link

ssjod commented Jan 6, 2020

Using homebrew's directory of v8 for --with-v8-dir=/usr/local/Cellar/[email protected]/3.15.11.18_1, instead of /usr/local/opt/v8-315, is what worked for me, in coding addicted's answer.

This is visible in the Summary of the brew install command, brew install v8-315.

@guillaumebihet
Copy link

guillaumebihet commented Mar 30, 2020

Same as previous comment, with specifying in addition the required version, as such:
gem install therubyracer -v '0.12.2' -- --with-v8-dir=/usr/local/Cellar/[email protected]/3.15.11.18_1

@hussainakram
Copy link
Member

I have tried all above mentioned but nothing did work. But updating mini_racer did work in my case:

bundle update mini_racer

It updates the version of libv8 from 6.7.288.46.1 to 7.3.492.27.1 which solves the issue.

In my case, bundle was stuck at this point for more than 30 mins even after multiple tries

Also raised the PR: #466

@jorgealdana30
Copy link

Worked for me as well although I had to change the gem install line to

gem install therubyracer -- --with-v8-dir=/usr/local/opt/[email protected]

Thanks!

This works for me, thanks!

@ghost
Copy link

ghost commented Jan 7, 2021

Worked for me as well although I had to change the gem install line to

gem install therubyracer -- --with-v8-dir=/usr/local/opt/[email protected]

Thanks!

This works perfect! thanks

@stevenjohn
Copy link

Hi there - I am following https://stackoverflow.com/questions/65810530/unable-to-install-therubyracer-v0-12-3-gem-in-m1-macbook-pro with interest as I have the same issue - getting ruby racer working on apple m1 silicon.

I can see:

steve@Steves-MacBook-Air task % gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8-315
Building native extensions with: '--with-v8-dir=/usr/local/opt/v8-315'
This could take a while...
ERROR:  Error installing therubyracer:
	ERROR: Failed to build gem native extension.

    current directory: /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/ext/v8
/Users/steve/.rbenv/versions/2.6.6/bin/ruby -I /Users/steve/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20210121-4665-1t2hzxy.rb extconf.rb --with-v8-dir\=/usr/local/opt/v8-315
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/Users/steve/.rbenv/versions/2.6.6/bin/$(RUBY_BASE_NAME)
	--with-pthreadlib
	--without-pthreadlib
	--with-objclib
	--without-objclib
	--enable-debug
	--disable-debug
	--with-v8-dir
	--with-v8-include
	--without-v8-include=${v8-dir}/include
	--with-v8-lib
	--without-v8-lib=${v8-dir}/lib
/Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with 
the libv8 rubygem. 

However, your system version of v8 could not be located. 

Please make sure your system version of v8 that is compatible 
with 3.16.14.19 installed. You may need to use the 
--with-v8-dir option if it is installed in a non-standard location
	from /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
	from extconf.rb:32:in `<main>'

I can see that v8 is installed and present:

steve@Steves-MacBook-Air task % brew --prefix v8-315                                                               
/opt/homebrew/Cellar/[email protected]/3.15.11.18_1

I can also try to use this path which I have seen as a fix for some people:

steve@Steves-MacBook-Air task % gem install therubyracer -- --with-v8-dir=/opt/homebrew/Cellar/[email protected]/3.15.11.18_1
Building native extensions with: '--with-v8-dir=/opt/homebrew/Cellar/[email protected]/3.15.11.18_1'
This could take a while...
ERROR:  Error installing therubyracer:
	ERROR: Failed to build gem native extension.

    current directory: /Users/steve/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/therubyracer-0.12.3/ext/v8
/Users/steve/.rbenv/versions/2.6.6/bin/ruby -I /Users/steve/.rbenv/versions/2.6.6/lib/ruby/2.6.0 -r ./siteconf20210121-4826-1rqvtx8.rb extconf.rb --with-v8-dir\=/opt/homebrew/Cellar/[email protected]/3.15.11.18_1
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***

... so seem to be stumped.

Has anyone succeed on getting ruby racer working on apple silicon?

Kind regards, Steve.

@justin808
Copy link
Member Author

@stevenjohn I recommend posting what you just posted to the therubyracer and mini_racer gems.

@stevenjohn
Copy link

Thanks @justin808

@TorvaldsDB
Copy link

MacOS Mojave install therubyracer version '0.12.2'

brew update brew install v8 gem install libv8 -v '3.16.14.15' -- --with-system-v8 gem install therubyracer -- --with-v8-dir=#{libv8_path}

on my computer, libv8_path is /usr/local/Cellar/v8/7.2.502.25

I tried step by step, but it still failed.

My laptop

image

and the failure detail:

bdu@CHEMMS-bdu ~ $ brew update                                                                                                                                                                                                                                                                                                                                     [system]
Already up-to-date.
bdu@CHEMMS-bdu ~ $ brew install v8                                                                                                                                                                                                                                                                                                                                 [system]
==> Downloading https://ghcr.io/v2/homebrew/core/v8/manifests/9.8.177.9
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/v8/blobs/sha256:122e44b93947e782b559967cfbadcc422b0781bf2507f50b994ab7a629ad735f
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:122e44b93947e782b559967cfbadcc422b0781bf2507f50b994ab7a629ad735f?se=2022-02-13T04%3A00%3A00Z&sig=ff40UMcfJFTloqITRkxToaGwmEjiXaEiW1ablGThrKw%3D&sp=r&spr=https&sr=b&sv=2019-12-12
######################################################################## 100.0%
==> Pouring v8--9.8.177.9.arm64_monterey.bottle.tar.gz
🍺  /opt/homebrew/Cellar/v8/9.8.177.9: 200 files, 43MB
==> Running `brew cleanup v8`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
bdu@CHEMMS-bdu ~ $ gem install libv8 -v '3.16.14.15' -- --with-system-v8                                                                                                                                                                                                                                                                                           [system]
Fetching libv8-3.16.14.15.gem
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
bdu@CHEMMS-bdu ~ $ sudo gem install libv8 -v '3.16.14.15' -- --with-system-v8                                                                                                                                                                                                                                                                                      [system]
Password:
Fetching libv8-3.16.14.15.gem
Building native extensions with: '--with-system-v8'
This could take a while...
Successfully installed libv8-3.16.14.15
1 gem installed
bdu@CHEMMS-bdu ~ $ gem install therubyracer -v '0.12.3' -- --with-v8-dir=/usr/local/opt/[email protected]                                                                                                                                                                                                                                                                    [system]
bdu@CHEMMS-bdu ~ $ cd /usr/local/opt/v                                                                                                                                                                                                                                                                                                                             [system]
bdu@CHEMMS-bdu ~ $ cd /usr/local/Cellar/                                                                                                                                                                                                                                                                                                                           [system]
bdu@CHEMMS-bdu ~ $ gem install therubyracer -- --with-v8-dir=/opt/homebrew/Cellar/v8/9.8.177.9                                                                                                                                                                                                                                                                     [system]
Fetching therubyracer-0.12.3.gem
Fetching ref-2.0.0.gem
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
bdu@CHEMMS-bdu ~ $ sudo gem install therubyracer -- --with-v8-dir=/opt/homebrew/Cellar/v8/9.8.177.9                                                                                                                                                                                                                                                                [system]

Fetching therubyracer-0.12.3.gem
Fetching ref-2.0.0.gem
Successfully installed ref-2.0.0
Building native extensions with: '--with-v8-dir=/opt/homebrew/Cellar/v8/9.8.177.9'
This could take a while...
ERROR:  Error installing therubyracer:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/therubyracer-0.12.3/ext/v8
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20220213-85625-ezs873.rb extconf.rb --with-v8-dir\=/opt/homebrew/Cellar/v8/9.8.177.9
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
	--with-opt-dir
	--without-opt-dir
	--with-opt-include
	--without-opt-include=${opt-dir}/include
	--with-opt-lib
	--without-opt-lib=${opt-dir}/lib
	--with-make-prog
	--without-make-prog
	--srcdir=.
	--curdir
	--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
	--with-pthreadlib
	--without-pthreadlib
	--with-objclib
	--without-objclib
	--enable-debug
	--disable-debug
	--with-v8-dir
	--with-v8-include
	--without-v8-include=${v8-dir}/include
	--with-v8-lib
	--without-v8-lib=${v8-dir}/lib
/Library/Ruby/Gems/2.6.0/gems/libv8-3.16.14.15/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with
the libv8 rubygem.

However, your system version of v8 could not be located.

Please make sure your system version of v8 that is compatible
with 3.16.14.15 installed. You may need to use the
--with-v8-dir option if it is installed in a non-standard location
	from /Library/Ruby/Gems/2.6.0/gems/libv8-3.16.14.15/lib/libv8.rb:7:in `configure_makefile'
	from extconf.rb:32:in `<main>'

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-21/2.6.0/therubyracer-0.12.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/therubyracer-0.12.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-21/2.6.0/therubyracer-0.12.3/gem_make.out

@sanjayvinzuda-simformsolutions

On MacOS Mojave this works:

install [email protected]
brew install [email protected]

edit profile(in my case vi ~/.zshrc) and add this:

export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

install therubyracer version in this case 0.12.2:
gem install therubyracer -v '0.12.2' -- --with-v8-dir=/usr/local/opt/[email protected]

Hope this will work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests