将jekyll与gitlab pages一起使用,它说当它使用gitlab CI部署网站时找不到主题,我已经安装了它

Using jekyll with gitlab pages, it says when it's deploying the website with gitlab CI that theme could not be found, and I already installed it

我的目标

要有一个包含 jekyll 站点配置文件(但不是 _site)的存储库,并且每次我推送到存储库时,都会运行一个 gitlab 管道。使用该管道,该站点是使用 Jekyll 构建的(我正在使用这个主题 https://github.com/mmistakes/jekyll-theme-basically-basic

快速浏览我遇到的基本文件

宝石文件

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", "~> 4.0.0"
# This is the default theme for new Jekyll sites. You may change this to anything you like.

#######
#THEMES
#######

# MANUALLY COMMENTED
#gem "minima", "~> 2.5"
# New content by me
#gem "jekyll-theme-basically-basic"
#gem 'jekyll-theme-basically-basic', '~> 1.4', '>= 1.4.4'

########################



# 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.12"
end

# Windows and JRuby does not include zoneinfo files, so bundle the tzinfo-data gem
# and associated library.
install_if -> { RUBY_PLATFORM =~ %r!mingw|mswin|java! } do
  # gem "tzinfo", "~> 1.2"
  # gem "tzinfo-data"
end

# Performance-booster for watching directories on Windows
# gem "wdm", "~> 0.1.1", :install_if => Gem.win_platform?

也许您想知道为什么那里有这么多评论。那是因为我在 gitlab 中部署时遇到了问题,我发现如果我将它们安装在 .gitlab-ci.yml 中,我就不会遇到这些问题。

_config.yml

# Welcome to Jekyll!
#
# This config file is meant for settings that affect your whole blog, values
# which you are expected to set up once and rarely edit after that. If you find
# yourself editing this file very often, consider using Jekyll's data files
# feature for the data you need to update frequently.
#
# For technical reasons, this file is *NOT* reloaded automatically when you use
# 'bundle exec jekyll serve'. If you change this file, please restart the server process.
#
# If you need help with YAML syntax, here are some quick references for you: 
# https://learn-the-web.algonquindesign.ca/topics/markdown-yaml-cheat-sheet/#yaml
# https://learnxinyminutes.com/docs/yaml/
#
# Site settings
# These are used to personalize your new site. If you look in the HTML files,
# you will see them accessed via {{ site.title }}, {{ site.email }}, and so on.
# You can create any custom variable you would like, and they will be accessible
# in the templates via {{ site.myvariable }}.

lang: es-ES
title: La casa de los titanes
email: adristudy@gmail.com
description: >- # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
author:
  name: Adrián Jaramillo
twitter_username: sample
github_username: sample

# Build settings
theme: jekyll-theme-basically-basic
#theme: minima
plugins:
  - jekyll-feed

# Exclude from processing.
# The following items will not be processed, by default.
# Any item listed under the `exclude:` key here will be automatically added to
# the internal "default list".
#
# Excluded items can be processed by explicitly listing the directories or
# their entries' file path in the `include:` list.
#
# exclude:
#   - .sass-cache/
#   - .jekyll-cache/
#   - gemfiles/
#   - Gemfile
#   - Gemfile.lock
#   - node_modules/
#   - vendor/bundle/
#   - vendor/cache/
#   - vendor/gems/
#   - vendor/ruby/

# New content by me 
# theme: jekyll-theme-basically-basic

.gitlab-ci.yml

image: ruby:2.5

pages:
  script:
  - gem install jekyll
  #- gem install minima
  - gem install jekyll-theme-basically-basic -v 1.4.1
  - gem install tzinfo -v 1.2.2
  - gem install tzinfo-data
  - bundle install
  - jekyll build --trace -d public/
  artifacts:
    paths:
    - public
  only:
  - master

此外,您在这里有 public 存储库

https://gitlab.com/unveiled_adri/jekyll_project

当然还有在gitlab的dockervm上部署的整个过程,显示报错

Running with gitlab-runner 12.3.0 (a8a019e0)
  on docker-auto-scale ed2dce3a
Using Docker executor with image ruby:2.5 ...
Pulling docker image ruby:2.5 ...
Using docker image sha256:092689b795107d1b2eadb82494acf4764191baa0aa5bf4673b8ee2a50f70ba97 for ruby:2.5 ...
Running on runner-ed2dce3a-project-14628881-concurrent-0 via runner-ed2dce3a-srm-1571178048-5f8825dc...
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/unveiled_adri/jekyll_project/.git/
Created fresh repository.
From https://gitlab.com/unveiled_adri/jekyll_project
 * [new ref]         refs/pipelines/89060084 -> refs/pipelines/89060084
 * [new branch]      master                  -> origin/master
Checking out 745d8811 as master...

Skipping Git submodules setup
$ gem install jekyll
Successfully installed public_suffix-4.0.1
Successfully installed addressable-2.7.0
Successfully installed colorator-1.1.0
Building native extensions. This could take a while...
Successfully installed http_parser.rb-0.6.0
Building native extensions. This could take a while...
Successfully installed eventmachine-1.2.7
Successfully installed em-websocket-0.5.1
Successfully installed concurrent-ruby-1.1.5

HEADS UP! i18n 1.1 changed fallbacks to exclude default locale.
But that may break your application.

Please check your Rails app for 'config.i18n.fallbacks = true'.
If you're using I18n (>= 1.1.0) and Rails (< 5.2.2), this should be
'config.i18n.fallbacks = [I18n.default_locale]'.
If not, fallbacks will be broken in your app by I18n 1.1.x.

For more info see:
https://github.com/svenfuchs/i18n/releases/tag/v1.1.0

Successfully installed i18n-1.7.0
Building native extensions. This could take a while...
Successfully installed ffi-1.11.1
Building native extensions. This could take a while...
Successfully installed sassc-2.2.1
Successfully installed jekyll-sass-converter-2.0.1
Successfully installed rb-fsevent-0.10.3
Successfully installed rb-inotify-0.10.0
Successfully installed listen-3.2.0
Successfully installed jekyll-watch-2.2.1
Successfully installed kramdown-2.1.0
Successfully installed kramdown-parser-gfm-1.1.0
Successfully installed liquid-4.0.3
Successfully installed mercenary-0.3.6
Successfully installed forwardable-extended-2.6.0
Successfully installed pathutil-0.16.2
Successfully installed rouge-3.12.0
Successfully installed safe_yaml-1.0.5
Successfully installed unicode-display_width-1.6.0
Successfully installed terminal-table-1.8.0
-------------------------------------------------------------------------------------
Jekyll 4.0 comes with some major changes, notably:

  * Our `link` tag now comes with the `relative_url` filter incorporated into it.
    You should no longer prepend `{{ site.baseurl }}` to `{% link foo.md %}`
    For further details: https://github.com/jekyll/jekyll/pull/6727

  * Our `post_url` tag now comes with the `relative_url` filter incorporated into it.
    You shouldn't prepend `{{ site.baseurl }}` to `{% post_url 2019-03-27-hello %}`
    For further details: https://github.com/jekyll/jekyll/pull/7589

  * Support for deprecated configuration options has been removed. We will no longer
    output a warning and gracefully assign their values to the newer counterparts
    internally.
-------------------------------------------------------------------------------------
Successfully installed jekyll-4.0.0
26 gems installed
$ gem install jekyll-theme-basically-basic -v 1.4.1
Successfully installed i18n-0.9.5
Successfully installed sass-listen-4.0.0

Ruby Sass has reached end-of-life and should no longer be used.

* If you use Sass as a command-line tool, we recommend using Dart Sass, the new
  primary implementation: https://sass-lang.com/install

* If you use Sass as a plug-in for a Ruby web framework, we recommend using the
  sassc gem: https://github.com/sass/sassc-ruby#readme

* For more details, please refer to the Sass blog:
  https://sass-lang.com/blog/posts/7828841

Successfully installed sass-3.7.4
Successfully installed jekyll-sass-converter-1.5.2
Successfully installed kramdown-1.17.0
Successfully installed jekyll-3.8.6
Successfully installed jekyll-sitemap-1.3.1
Successfully installed jekyll-seo-tag-2.6.1
Successfully installed jekyll-paginate-1.1.0
Successfully installed jekyll-feed-0.12.1
Successfully installed jekyll-theme-basically-basic-1.4.1
11 gems installed
$ gem install tzinfo -v 1.2.2
Successfully installed thread_safe-0.3.6
Successfully installed tzinfo-1.2.2
2 gems installed
$ gem install tzinfo-data
Successfully installed tzinfo-data-1.2019.3
1 gem installed
$ bundle install
Fetching gem metadata from https://rubygems.org/...........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Using public_suffix 4.0.1
Using addressable 2.7.0
Using bundler 1.17.3
Using colorator 1.1.0
Using concurrent-ruby 1.1.5
Using eventmachine 1.2.7
Using http_parser.rb 0.6.0
Using em-websocket 0.5.1
Using ffi 1.11.1
Using forwardable-extended 2.6.0
Using i18n 1.7.0
Using sassc 2.2.1
Using jekyll-sass-converter 2.0.1
Using rb-fsevent 0.10.3
Using rb-inotify 0.10.0
Using listen 3.2.0
Using jekyll-watch 2.2.1
Using kramdown 2.1.0
Using kramdown-parser-gfm 1.1.0
Using liquid 4.0.3
Using mercenary 0.3.6
Using pathutil 0.16.2
Using rouge 3.12.0
Using safe_yaml 1.0.5
Using unicode-display_width 1.6.0
Using terminal-table 1.8.0
Using jekyll 4.0.0
Using jekyll-feed 0.12.1
Bundle complete! 2 Gemfile dependencies, 28 gems now installed.
Bundled gems are installed into `/usr/local/bundle`
$ jekyll build --trace -d public/
Configuration file: /builds/unveiled_adri/jekyll_project/_config.yml
/usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/theme.rb:76:in `rescue in gemspec': The jekyll-theme-basically-basic theme could not be found. (Jekyll::Errors::MissingDependencyException)
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/theme.rb:73:in `gemspec'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/theme.rb:18:in `root'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/theme.rb:12:in `initialize'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/site.rb:487:in `new'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/site.rb:487:in `configure_theme'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/site.rb:58:in `config='
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/site.rb:23:in `initialize'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:30:in `new'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:30:in `process'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `block in process_with_graceful_fail'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `each'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/command.rb:89:in `process_with_graceful_fail'
    from /usr/local/bundle/gems/jekyll-4.0.0/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
    from /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
    from /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
    from /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
    from /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
    from /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
    from /usr/local/bundle/gems/jekyll-4.0.0/exe/jekyll:15:in `<top (required)>'
    from /usr/local/bundle/bin/jekyll:23:in `load'
    from /usr/local/bundle/bin/jekyll:23:in `<main>'
ERROR: Job failed: exit code 1

结论

我已经尝试了所有方法,但在部署的最后一刻我完全迷失了方向。我可以解决安装问题,但现在我不知道如何解决。

在您的 Gemfile 中,取消注释 #gem "jekyll-theme-basically-basic" 以阅读 gem "jekyll-theme-basically-basic"

出于某些原因,在您的 .gitlab-ci.yml 中,所有 gem install ... 都是无用的,bundle install 可以完成所需的工作。