微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Jekyll 在本地 mac 机器上安装失败

如何解决Jekyll 在本地 mac 机器上安装失败

user@me-MacBook-Pro jekyll-site % sudo bundle exec jekyll serve

Could not find therubyracer-0.12.3 in any of the sources
Run `bundle install` to install missing gems.

现在我运行 bundle install,它一直运行到 Installing therubyracer 0.12.3 with native extensions在这一步,它抛出一个错误

/Library/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.

还有,

An error occurred while installing therubyracer (0.12.3),and Bundler cannot continue.
Make sure that `gem install therubyracer -v '0.12.3' --source 'https://rubygems.org/'` succeeds before bundling.

然后按照这里的建议,我运行了以下命令:

gem install therubyracer -v '0.12.3' --source 'https://rubygems.org/'

它给出了另一个错误


Using compiler: c++ (clang version 12.0.0)
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=c++ LINK=c++  /usr/bin/make 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  -Dv8_enable_backtrace=1 -Dv8_can_use_vfp2_instructions=true -Darm_fpu=vfpv2 -Dv8_can_use_vfp3_instructions=true -Darm_fpu=vfpv3 -Dwerror=''
  CXX(target) /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o
clang: warning: include path for libstdc++ headers not found; pass '-stdlib=libc++' on the command line to use the libc++ standard library instead [-Wstdlibcxx-not-found]
In file included from ../src/allocation.cc:33:
../src/utils.h:33:10: Fatal error: 'climits' file not found
#include <climits>
         ^~~~~~~~~
1 error generated.
make[1]: *** [/Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/vendor/v8/out/x64.release/obj.target/preparser_lib/src/allocation.o] Error 1
make: *** [x64.release] Error 2
/Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:36:in `block in verify_installation!': libv8 did not install properly,expected binary v8 archive '/Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/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/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `each'
    from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:35:in `verify_installation!'
    from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:26:in `install!'
    from extconf.rb:7:in `<main>'

extconf Failed,exit code 1

Gem files will remain installed in /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/libv8-3.16.14.19 for inspection.
Results logged to /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/extensions/x86_64-darwin-20/2.5.0/libv8-3.16.14.19/gem_make.out

如何解决这个问题并在本地机器上运行 Jekyll?

解决方法

therubyracer 的作用是为在 ruby​​ 中解释 JS 提供一个很好的接口。当然,它在后台使用 V8 运行时。

所以你的日志中的关键信息是:

However,your system version of v8 could not be located.
Unable to find a compiler officially supported by v8.

编译器

libv8 是一个 ruby​​ gem,它为 ruby​​ 应用程序分发 v8 运行时。正如错误消息所说,它建议使用 gcc 作为编译器。

所以安装 gcc 并重试。

$ brew install gcc

libv8 现在应该正在构建,therubyracer

也是如此

系统 V8

如果仍然缺少某些东西,还有另一种选择:使用系统安装的 v8 而不是 libv8 gem 提供的那个。

首先确保您的系统上安装了 V8。它可能还会将受支持的编译器作为依赖项。

$ brew install v8

然后在安装 libv8 时使用 --with-system-v8 标志。

$ gem install libv8 -- --with-system-v8

如果您计划将 V8 运行时用于除 therubyracer 之外的其他事情,这可能很有用。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。