ruby - 如何修复 Jekyll “找不到 JavaScript 运行时”错误
问题描述
我目前正在尝试将 Jekyll 上传到 Gitlab 页面,但是,由于某种原因,我一直在管道中遇到相同的错误消息:
$ bundle exec jekyll build -d public
Configuration file: /builds/mmellows1/mighty/_config.yml
jekyll 3.8.6 | Error: Could not find a JavaScript runtime. See https://github.com/rails/execjs for a list of available runtimes.
ERROR: Job failed: exit code
我的 GEM 文件如下所示:
source "https://rubygems.org"
# Hello! This is where you manage which Jekyll version is used to run.
# When you want to use a different version, change it below, save the
# file and run `bundle install`. Run Jekyll with `bundle exec`, like so:
#
# bundle exec jekyll serve
#
# This will help ensure the proper Jekyll version is running.
# Happy Jekylling!
gem "jekyll", "~> 3.8.4"
# This is the default theme for new Jekyll sites. You may change this to anything you like.
gem "minima", "~> 2.0"
# If you want to use GitHub Pages, remove the "gem "jekyll"" above and
# uncomment the line below. To upgrade, run `bundle update github-pages`.
# gem "github-pages", group: :jekyll_plugins
# If you have any plugins, put them here!
group :jekyll_plugins do
gem "jekyll-feed", "~> 0.6"
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby]
# Performance-booster for watching directories on Windows
gem "wdm", "~> 0.1.0" if Gem.win_platform?
gem 'jekyll-compose', group: [:jekyll_plugins]
gem 'jekyll-autoprefixer'
我的 gitlab-ci.yml 文件如下所示:
pages:
image: ruby:2.3
variables:
JEKYLL_ENV: staging
LC_ALL: C.UTF-8
before_script:
- bundle install
stage: deploy
script:
- bundle exec jekyll build -d public
artifacts:
paths:
- public
only:
- master
解决方案
https://github.com/rails/execjs下列出了许多选项(如错误所示)。您需要在 Gemfile 中添加一个包含 JavaScript 运行时的 gem。
我倾向于使用therubyracer
,像这样将它添加到您的 Gemfile 中:
gem "therubyracer"
推荐阅读
- java - 使用 Spark 和 java 编写 CSV 文件 - 处理空值和引号
- android - 如何在 XML GridView 中使宽度比相等
- angular - 如何以角度将数组绑定到ngModel并检测更改
- python - 什么会导致 sock connect() 命令出现“资源暂时不可用”
- c++ - 如果我不使用 C++11,如何实现 std::move() 替代方案?
- php - 为什么模型/变量保持其价值?
- angular - 使用 RxJs ConcatMap 不要发送 null 值或空字符串
- c++ - 首次访问时分配的智能指针
- android - 初始屏幕 GIF 反应原生
- swing - 我可以自定义 Install4j 中的内置浏览按钮吗?