1.在安装 gem ‘therubyracer’ 报错了
首先是libv8报错
Installing libv8 3.16.14.19 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. and
the fact that we don’t need and probably you don’t need therubyracer.There are two solutions for the above error:
向上方的报错、或者是 提示我runing gem install libv8 --source… 这些
按照自带提示安装了一下、没好用。
1.以下解决方案
gem install libv8 -v ‘3.16.14.3’ – --with-system-v8
这个安装后到是好用了、但是出现了其他错误:Installing therubyracer 0.12.3 with native extensions
therubyracer -v ‘0.12.3’ – --with-v8-dir=… 这样的错误
国内百度了一下,除了删除gem 缓存就没有其他解决方案了,这很不好。
我这里归档了一些系统的解决方案(CenterOS、MAC、Ubuntu)
MAC方案1.我的解决方案 macOS 10.15 系统
这里使用你自己的版本号
brew install v8@3.15
gem install libv8 -v 'YOUR_VERSION' -- --with-system-v8
gem install therubyracer -v 'YOUR_VERSION' -- --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
方案2:
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
方案3
brew install v8@3.15
bundle config --local build.libv8 --with-system-v8
bundle config --local build.therubyracer --with-v8-dir=/usr/local/opt/v8@3.15
bundle install
Center OS系统环境:(Ubuntu也可以这么干但是不用去掉gem)
顺便提一下:我在centerOS环境没有解决该问题(以上方法全部试过了)
经过2天的查阅,我注视了
#gem ‘execjs’
#gem ‘therubyracer’, :platforms => :ruby
采用了 sudo yum install nodejs ,也可以解决生产对js依赖(nodejs可以替代他们,很多人推荐使用nodejs 而不是 他俩)