-
-
Save fernandoaleman/868b64cd60ab2d51ab24e7bf384da1ca to your computer and use it in GitHub Desktop.
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 |
These steps did not work for me on Catalina using the system Ruby; I used
ruby-2.6.3
via RVM and things worked.
@jkingsman Thanks for noting this! Switching away from the system version of ruby was the only way I could get this working.
Note to readers, this is in reference to steps to do things like:
$ brew install [email protected]
$ bundle config build.libv8 --with-system-v8
$ bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
$ bundle install
@KyleAsaff - I had this exact problem. It was maddening. You need to remove 'therubyracer' gem, and remove the 'less' gem and the 'less-rails' gem, assuming you're using one of them. They depend on TheRubyRacer to supply a JS runtime. You don't need it, as most systems have node now.
To preserve the less/scss functionality, use the 'sassc-rails' gem instead.
I called NodeJS out explicitly as my JS Runtime in the config/boot.rb file, but I also tried running the app without that line and it seems to fine without it.
I hope this helps.
Has anyone got this working on OSX 12.1? These guides are not working correctly.
current directory: /Users/christopherhough/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/sq_mini_racer-0.2.5.0.1.beta3/ext/mini_racer_extension
/Users/christopherhough/.rbenv/versions/2.5.7/bin/ruby -r ./siteconf20220110-69812-1jjiy7b.rb extconf.rb
ERROR: found libv8-7.3.492.27.1, but no binary for x86_64-darwin-21
try "gem install libv8 -v '7.3.492.27.1'" to attempt to build libv8 from source
*** 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/christopherhough/.rbenv/versions/2.5.7/bin/$(RUBY_BASE_NAME)
detected platform x86_64-darwin21 => x86_64-darwin-21
looking for libv8-7.3.492.27.1-x86_64-darwin-21.gemspec in installed gems
libv8-7.3.492.27.1-x86_64-darwin-21.gemspec not found in installed gems
looking for libv8-7.3.492.27.1-x86_64-darwin-21 in /Users/christopherhough/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/sq_mini_racer-0.2.5.0.1.beta3/ext/mini_racer_extension/vendor
libv8-7.3.492.27.1-x86_64-darwin-21 not found in /Users/christopherhough/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/sq_mini_racer-0.2.5.0.1.beta3/ext/mini_racer_extension/vendor
extconf failed, exit code 1
Gem files will remain installed in /Users/christopherhough/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/gems/sq_mini_racer-0.2.5.0.1.beta3 for inspection.
Results logged to /Users/christopherhough/.rbenv/versions/2.5.7/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-21/2.5.0/sq_mini_racer-0.2.5.0.1.beta3/gem_make.out
An error occurred while installing sq_mini_racer (0.2.5.0.1.beta3), and Bundler cannot continue.
Make sure that `gem install sq_mini_racer -v '0.2.5.0.1.beta3'` succeeds before bundling.```
@chrishough Im using OSX 12.1
And still working for me: https://gist.github.com/fernandoaleman/868b64cd60ab2d51ab24e7bf384da1ca#gistcomment-3645557
Has anyone gotten this to work for Ruby 3.1? I'm running into an issue where libv8 isn't able to be ran when upgrading to this ruby version.
@eveevans so you could not get this to work in standard homebrew?
@chrishough yes indeed, I'm using ASDF for Ruby (and Node)
@eveevans from your command list I originally read that using arch linux, but I am new to asdf
@chrishough you will need brew, but the thing about it, is that there are two versions of homebrew for Silicon macs, the one for ARM (by default), and the one for Intel (which needs to be run under Rosetta)
In the time I installed Ruby there were a lot of Brew package unavailable for ARM. So I used the Intel version (X86) in order to install the X86 version of ASDF, using X86 dependencies
(In my case, I was using and old Ruby that needed old dependencies)
@eveevans I am having this issue on both an M1 and non-m1 machine, trying to fix the non-m1 first
I worked on this work around. It worked for me and I've never had any issues.
It's kinda long but a Turing instructor and I worked on this.
One of the answers in the answers also might work too
Has someone been able to build libv8 on a PowerPC Mac?
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
bundle
Worked on MacBook Pro 2020
@BDanyil are you running macos monterey 12.2 on intel? i tried following the installing but its not working for monterey. thank you for your response
Still works just fine with my env Catalina, Ruby 2.6.6, and Rails 6.0.4.2
On my Apple M1 with MySQL 5.7 and [email protected] with Ruby 2.6.5.x
bundle config build.mysql2
--with-mysql-config=/opt/homebrew/Cellar/[email protected]/5.7.36/bin/mysql_config
--with-ldflags=-L/opt/homebrew/opt/[email protected]/lib
--with-cppflags=-I/opt/homebrew/opt/[email protected]/include
bundle install # installed mysql2 with native gems just fine
After hours of dealing with this, I finally found a solution that worked for me. Big Sur 11.6 - Intel
env \ CXX=clang++ \ GYPFLAGS=-Dmac_deployment_target=10.9 \ gem install libv8 --version 3.16.14.19
then run
bundle install
Hope this helps!
This one worked for me as well! Thank you very much
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
bundle
worked for me, thanks
bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
worked for me, thanks
macOS Monterey doesn't include Python 2 anymore. Python 2 is required by libv8. To install it (from https://www.alfredapp.com/help/kb/python-2-monterey/), execute the following (preferably in a new shell because it changes $PATH):
export PATH="/opt/homebrew/bin:/usr/local/bin:${PATH}"
eval "$(brew shellenv)"
brew install pyenv
pyenv install 2.7.18
ln -s "${HOME}/.pyenv/versions/2.7.18/bin/python2.7" "${HOMEBREW_PREFIX}/bin/python"
For Ruby 3.0.4 in Monterey (macOS 12.3.1), this worked for me:
brew install [email protected]
bundle config build.libv8 --with-system-v8
bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
bundle install
Unfortunately, it's not so easy in Ruby. 3.1. That includes psych-4 as a "default" (hard-coded in) gem which can't be removed, and psych-4 is incompatible with libv8 (for now at least). I have not found a solution to this, aside from reverting to ruby 3.0.4.
For those who any of the above fixes didn't work I installed Python 3.9.1 set it to the global python version (setting it to local version didn't work), and ran bundle again and it installed mini_racer correctly.
What tipped me off was the following message in the console output after it failed:
Python 3.12. Use setuptools or check PEP 632 for potential alternatives
from distutils.spawn import find_executable
Please use python3.9 or python3.8 or python3.7 or python3.6 or python3.5 or python2.7.
Node.js configure: Found Python 3.10.2...
Here are the commands I ran:
pyenv install 3.9.1
pyenv global 3.9.1
bundle
if someone is using mini_racer 0.3.0
or below, please upgrade to gem 'mini_racer', '0.6.2'
and comment out libv8
trust me, it will save you hours of dev config time
Much thanks @gamesover This was the perfect fix for Monterey 12.4 on a M1.
if someone is using
mini_racer 0.3.0
or below, please upgrade togem 'mini_racer', '0.6.2'
and comment outlibv8
trust me, it will save you hours of dev config time
Still not working on [email protected] the only way out is reverting to ruby 3.0.4
Comment out Following 2 Gems from Gemfile
1: g em 'libv8'
2: gem 'therubyracer'
Add following Gem
gem 'mini_racer'
bundle install
Should work as suggested by @srfinkel
Still not working on [email protected], any solutions??
Not working on [email protected] yet
bundle config build.therubyracer --with-v8-dir=$(brew --prefix [email protected])
Thanks. Worked for me too!
After hours of dealing with this, I finally found a solution that worked for me.
Big Sur 11.6 - Intel
env \ CXX=clang++ \ GYPFLAGS=-Dmac_deployment_target=10.9 \ gem install libv8 --version 3.16.14.19
then run
bundle install
Hope this helps!