1

我目前正在尝试将 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
4

2 回答 2

2

https://github.com/rails/execjs下列出了许多选项(如错误所示)。您需要在 Gemfile 中添加一个包含 JavaScript 运行时的 gem。

我倾向于使用therubyracer,像这样将它添加到您的 Gemfile 中:

gem "therubyracer"
于 2020-02-25T00:06:24.217 回答
1

您需要在 ruby​​ 上安装 javascript 运行时。最简单的方法是在 before_script 部分安装 nodejs 本身。你的 gitlab-ci.yml 应该是这样的:

image: ruby:2.3

variables:
  JEKYLL_ENV: production
  LC_ALL: C.UTF-8

before_script:
  - apt update -qq && apt install -yqq nodejs
  - bundle install
....
于 2021-07-07T05:15:28.080 回答