1
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?

4

1 回答 1

0

什么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 而不是libv8gem 提供的。

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

$ brew install v8

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

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

如果您计划将 V8 运行时用于除therubyracer.

于 2021-04-07T09:35:01.200 回答