Techioz Blog

mini_racer および libv8-node をインストールするための gem ネイティブ拡張機能 (Windows 10) のビルドに失敗しました

概要

jekyll を使用して Web サイトを生成するために、bundle exec jekyllserve を使用しようとしましたが、次の結果が返されました。

それでバンドルインストールをしました

そしてこのエラーが発生しました:

Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Installing libv8-node 18.16.0.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

current directory:
D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-node-18.16.0.0/ext/libv8-node
D:/Ruby32-x64/bin/ruby.exe extconf.rb
creating Makefile
D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-node-18.16.0.0/ext/libv8-node/builder.rb:12:in
`build_libv8!': failed to download node 18.16.0 (Libv8::Node::BuilderError)
from
D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-node-18.16.0.0/ext/libv8-node/location.rb:30:in
`install!'
        from extconf.rb:15:in `<main>'
==== in
D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-node-18.16.0.0/ext/libv8-node
==== running
D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-node-18.16.0.0/libexec/download-node

extconf failed, exit code 1

An error occurred while installing libv8-node (18.16.0.0), and Bundler cannot
continue.

In Gemfile:
  mini_racer was resolved to 0.8.0, which depends on
    libv8-node

gem install libv8 も試してみましたが、次のように返されました。

Fetching libv8-8.4.255.0.gem
Temporarily enhancing PATH for MSYS/MINGW...
WARNING:  libv8-8.4.255.0 ships with a dangling symlink named vendor/depot_tools/cbuildbot pointing to missing vendor/depot_tools/cros file. Ignoring
WARNING:  libv8-8.4.255.0 ships with a dangling symlink named vendor/depot_tools/chrome_set_ver pointing to missing vendor/depot_tools/cros file. Ignoring
WARNING:  libv8-8.4.255.0 ships with a dangling symlink named vendor/depot_tools/cros_sdk pointing to missing vendor/depot_tools/cros file. Ignoring
Building native extensions. This could take a while...
ERROR:  Error installing libv8:
        ERROR: Failed to build gem native extension.

    current directory: D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-8.4.255.0/ext/libv8
D:/Ruby32-x64/bin/ruby.exe extconf.rb
creating Makefile
The system cannot find the path specified.

D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-8.4.255.0/ext/libv8/builder.rb:57:in `setup_python!': libv8 requires python 2 to be installed in order to build, but it is currently not available (RuntimeError)
        from D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-8.4.255.0/ext/libv8/builder.rb:39:in `build_libv8!'
        from D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-8.4.255.0/ext/libv8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in D:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/libv8-8.4.255.0 for inspection.
Results logged to D:/Ruby32-x64/lib/ruby/gems/3.2.0/extensions/x64-mingw-ucrt/3.2.0/libv8-8.4.255.0/gem_make.out

gem update も試してみましたが、gem が更新されたことがわかりました。また、winget で Ruby-dev をインストールしたところ、次の結果が返されました。

解決策

「therubyracer」を使用して「mini_racer」を置き換え、Windows システム上で「bundle install」と「bundle exec jekyll s」を正常に完了しました。このデバイスを受け取っていただければ幸いです。