我正在尝试安装libv8 3.16.14.3,但使用最新的稳定版rvm和ruby-1.9.3-p125在OSX Mavericks上出错。
这是运行命令'gem install libv8'的输出:
~/src(branch:master) » gem install libv8
Fetching: libv8-3.16.14.3.gem (100%)
Building native extensions. This could take a while...
ERROR: Error installing therubyracer:
ERROR: Failed to build gem native extension.
/Users/me/.rvm/rubies/ruby-1.9.3-p125/bin/ruby extconf.rb
creating Makefile
Compiling v8 for x64
Using python 2.7.5
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
Using compiler: g++
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Unable to find a compiler officially supported by v8.
It is recommended to use GCC v4.4 or higher
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make[1]: *** [/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a] Error 1
make: *** [x64.release] Error 2
/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly, expected binary v8 archive '/Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/tools/gyp/libv8_base.a'to exist, but it was not found (Libv8::Location::Vendor::ArchiveNotFound)
from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `each'
from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:35:in `verify_installation!'
from /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/location.rb:26:in `install!'
from extconf.rb:7:in `<main>'
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
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/atomicops_internals_x86_gcc.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/bignum-dtoa.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/cached-powers.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/conversions.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/diy-fp.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/dtoa.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fast-dtoa.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/fixed-dtoa.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/once.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparse-data.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/preparser-api.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/scanner.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/strtod.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/token.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/unicode.o
CXX(target) /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/obj.target/preparser_lib/src/utils.o
LIBTOOL-STATIC /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/vendor/v8/out/x64.release/libpreparser_lib.a
Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.3-p125@proj-rails3-ruby19/gems/libv8-3.16.14.3/ext/libv8/gem_make.out
答案 0 :(得分:441)
这是因为OS X 10.9+使用的是GCC 4.8版本。在拉取请求(https://github.com/cowboyd/libv8/pull/95)中提到的旧版本的libv8中,官方不支持此功能。请尝试在你的Gemfile(或)中提升libv8的版本bundle update
就足够了。希望这会有所帮助。
来自libv8 README
自带V8
因为libv8是therubyracer使用的V8引擎的接口,所以即使已经安装了V8,也可能需要使用libv8。如果您希望使用自己的V8安装,而不是为您构建它,请使用--with-system-v8选项。
使用RubyGems:
gem install libv8 [-v YOUR_VERSION] - --with-system-v8
使用Bundler(在你的Gemfile中):
捆绑配置build.libv8 --with-system-v8
请注意,如果您打算运行自己的V8,则必须安装V8及其标头(在Debian发行版的libv8-dev中找到)。
带上您自己的编译器
您可以通过在编译之前设置CXX环境变量,或者通过在bundle配置中添加--with-cxx =选项来指定您选择的编译器:
bundle config build.libv8 --with-cxx = clang ++
编辑:
如果therubyracer
引发了此问题,请按照rider_on_rails here的建议尝试以下操作:
gem uninstall libv8
gem install therubyracer -v YOUR_RUBY_RACER_VERSION
gem install libv8 -v YOUR_VERSION - --with-system-v8
答案 1 :(得分:212)
您可以在Mavericks上实际安装该版本:
gem install libv8 -v 3.11.8.17 -- --with-system-v8
我可以确认这适用于rbenv和ruby 1.9.3p448
答案 2 :(得分:35)
El Capitan解决方案对我来说:
$ brew install v8
$ gem install libv8 -v REQUIRED_LIBV8_VERSION -- --with-system-v8
我REQUIRED_LIBV8_VERSION
3.16.14.7
的位置4.2.5
,但您需要检查捆绑中需要的那个(这是rails 'ACCENTURE_PASSIVE_CANDIDATES', '1', 'LD_INDEX', '1', 'LOCATION_DISTANCE', 'A', '37876', NULL, NULL, 'YES', 'BTREE', '', ''
'ACCENTURE_PASSIVE_CANDIDATES', '1', 'RS_INDEX', '1', 'RELEVANCY_SCORE', 'A', '21996', NULL, NULL, 'YES', 'BTREE', '', ''
'ACCENTURE_PASSIVE_CANDIDATES', '1', 'score_index', '1', 'RELEVANCY_SCORE', 'A', '146566', NULL, NULL, 'YES', 'BTREE', '', ''
'ACCENTURE_PASSIVE_CANDIDATES', '1', 'location_index', '1', 'LOCATION_DISTANCE', 'A', '172873', NULL, NULL, 'YES', 'BTREE', '', ''
的那个)
您可能还需要以超级用户身份运行上述命令(如果您的宝石和系统库是全局的)
答案 3 :(得分:14)
当我尝试接受的答案时,libv8会成功安装gem install libv8
,但bundle install
会在libv8上失败。我认为bundle install
试图安装不同版本的libv8。我能够找到适合我的解决方案。
我需要libv8,因为therubyracer依赖于它。为了安装它,我注意到在gem_make.out
日志中未能安装的版本用于therubyracer。 (gem_make.out
日志的路径将出现在失败消息中。)在我的情况下,它是3.16.14.7。 (这个版本可能会随着时间的推移而发生变化,以防你从现在开始读这三年。)然后我就这样做了:
gem install libv8 -v 3.16.14.7 -- --with-v8-lib
&lt; - 注意接受答案的不同标志
允许这个工作:
gem install therubyracer
允许我完成bundle install
。
这对OSX优胜美地有用。
答案 4 :(得分:7)
https://github.com/cowboyd/therubyracer/issues/339
jasonlynes在该链接上找到的解决方案为我提供了诀窍。其他任何东西都不起作用。
brew install homebrew/versions/v8-315
brew link --overwrite v8-315 --force
gem install libv8 -v '3.16.14.13' -- --with-system-v8
gem install therubyracer -v '0.12.2' -- --with-system-v8
答案 5 :(得分:3)
这些都无济于事...无论我做什么,我安装的therubyracer的gem一直抱怨此错误:
SELECT f.*, MAX(url) AS url
FROM fruits AS f
LEFT JOIN images AS i ON f.idfruit = i.idfruit_image
GROUP BY f.idfruit
最终帮助我的是我在https://www.bountysource.com/issues/82833405-libv8-fails-to-build-on-catalina-10-15偶然发现的另一个论坛
对我有用的最终解决方案:
我必须将这些行添加到我的.zshrc文件中:
displayDirection(_origin, destin) {
var ref = this;
console.log('DIRECTION');
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
directionsDisplay.setMap(ref.map)
directionsService.route({
origin: _origin,
destination: destin,
travelMode: 'DRIVING'
}, (response, status) => {
console.log("Response: " + response + " Status: " + status);
if (status === 'OK') {
directionsDisplay.setDirections(response);
} else {
console.log("Can't set directions due to " + response);
}
});
}
然后我必须运行以下命令:
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=clang++ LINK=clang++ /usr/local/bin/gmake 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 -Dmac_deployment_target=10.15 -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror=''
File "build/gyp/gyp", line 12
except ImportError, e:
^
SyntaxError: invalid syntax
gmake: *** [Makefile:268: out/Makefile.x64] Error 1
我希望其他人觉得这有用!
答案 6 :(得分:3)
尝试我在此问题中总结的内容:"gem install therubyracer -v '0.10.2'" on osx mavericks not installing
它对我有用(OS X Mavericks)
答案 7 :(得分:3)
我更新为 macOS Catalina @ 10.15 和 ruby 2.6.5
。过了一会儿,再次安装了libv8
和therubyracer
,尽管我建议不要更新macOS(听说ruby
应该没问题)。
首先,我必须更新XCode
xcode-select --install
我使用rbenv
更新了ruby
,并将ruby
中的/Users/<username>/.rbenv/version
版本手动设置为2.6.5
。尽管您的项目是否包含.ruby-version
文件也没关系。
然后,我清理了libv8
(通常在/usr/local/opt/
中安装的任何版本):brew uninstall v8
,brew uninstall libv8@3.15
brew install v8@3.15
现在,在https://github.com/cowboyd/libv8#do-i-get-a-binary之后,我安装了
gem install libv8 -v '3.16.14.19' -- --with-system-v8
然后可以正确运行bundle install
。
答案 8 :(得分:1)
这对我来说很好:
尝试安装此预编译的gem:
https://dl.dropboxusercontent.com/u/7919548/gems/libv8/libv8-3.11.8.17-x86_64-darwin-13.gem (SHA1:5ce07aaf4085fff5a5e10fe018fd6b22021bef3b)
或者如果你想建立自己的:
git clone https://github.com/cowboyd/libv8.git
cd libv8
git checkout 3.11
bundle install
bundle exec rake clean build binary
gem install pkg/libv8-3.11.8.17-x86_64-darwin-13.gem
来源:https://github.com/cowboyd/libv8/issues/107
感谢Felix Bünemann的修复!
答案 9 :(得分:1)
当我从OSX Mountain Lion升级到OSX Mavericks时,我遇到了同样的问题。 接受的答案适用于libv8,但是当我去捆绑安装therubyracer gem时没有。
从ruby-1.8.7-p354升级到ruby-1.8.7-375对我来说是个窍门。 libv8(3.16.14.3-x86_64-darwin-13)和therubyracer(0.12.0)宝石安装没有问题。
假设您使用rbenv:
rbenv versions
system
* 1.8.7-p354
2.0.0-rc2
rbenv uninstall 1.8.7-p354
rbenv install 1.8.7-p375
rbenv versions
system
* 1.8.7-p375
2.0.0-rc2
bundle install
答案 10 :(得分:1)
您可以配置捆绑程序,而不必知道每个版本。 @ 3.15可以替换为其他版本。
input.sendKeys(Keys.CONTROL, Keys.chord("a")); //select all text in textbox
input.sendKeys(Keys.BACK_SPACE); //delete it
input.sendKeys("new text"); //enter new text
答案 11 :(得分:1)
我尝试了之前答案中概述的一些解决方案,但发现运行bundle(安装其他缺少的gems)会尝试重新编译libv8(尽管已经使用--with-system-v8
成功安装了它),因此遭受同样的问题。
最终,我发现删除libv8 gem,从rubygems获取gem文件,然后手动安装带有.gem
标志的--with-system-v8
文件对我有效。
即
gem uninstall libv8
gem fetch libv8 -v LIBV8_VERSION
gem install libv8-LIBV_VERSION.gem -- --with-system-v8
bundle
谢谢 Gaurav Agarwal's answer引导我走上正确的道路!
答案 12 :(得分:0)
这对我有用。
将3.16.14.7
替换为您的版本。
bundle install
gem install libv8 -v '3.16.14.7' -- --with-system-v8
bundle install
gem uninstall libv8 -v '3.16.14.7' -- --with-system-v8
brew install homebrew/dupes/apple-gcc42
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
bundle install
答案 13 :(得分:0)
我的问题是自therubyracer
起,当更新为macOS 10.15
和ruby-2.6.5
以下对我有用:
brew install v8@3.15
gem install libv8 -v 3.16.14.19 -- --with-system-v8
gem install therubyracer -- --with-v8-dir=/usr/local/opt/v8@3.15
答案 14 :(得分:0)
我在另一个项目中使用了Xcode的测试版并且忘记了。切换回xcode-select
。类似的东西:
sudo xcode-select --switch /Applications/Xcode.app/
答案 15 :(得分:0)
我在El Cap遇到过类似的问题。这就是我的所作所为。
brew tap homebrew/dupes
brew install apple-gcc42
然后,
export CC=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/gcc-4.2
export CXX=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/g++-4.2
export CPP=/usr/local/Cellar/apple-gcc42/4.2.1-5666.3/bin/cpp-4.2
最后,
brew uninstall v8
gem install libv8 -v 3.11.8.17 -- --with-system-v8
答案 16 :(得分:0)
对我来说真正有用的是将ruby升级到2.2.0,删除Gemfile.lock并重新捆绑。
像魅力一样工作!
答案 17 :(得分:0)
在具有RVM环境和ruby-2.1.1版本的MAC-Yosemite中
gem install libv8 -v 3.16.14.3 -- --with-v8-lib
gem install therubyracer
在上述命令的帮助下工作,可以确认这一点。
答案 18 :(得分:0)
您可以尝试通过the libv8 github site.
中提到的方法手动编译和安装gem答案 19 :(得分:-6)
从Gemfile中删除:
gem'therubyracer',: platforms =&gt; :红宝石