我是 Ruby/Jekyll 新手,但我想在 Windows 机器上本地安装 Jekyll,并使用下载的主题构建一个网站。我很难让它运行。我尝试使用的主题是Contrast 主题。我采取的步骤如下:
- 按照说明,首先使用此处的Ruby 安装程序安装 Ruby (选择版本Ruby+Devkit 3.3.7-1 [x64])。安装结束时,运行ridk install选项,并安装MSYS2 基础安装以及MSYS2 和 MINGW 开发工具链。
- 在命令提示符下运行
gem install jekyll bundler
,结果如下:
>bundler -v
Bundler version 2.6.7
>gem -v
3.5.22
>jekyll -v
jekyll 4.4.1
- 下载了对比度主题的 zip 文件并解压。解压后得到以下文件:
myuser@mymachine MINGW64 ~/contrast-master
$ ls
_config.yml _includes/ _posts/ 404.html assets/ Gemfile.lock README.md
_data/ _layouts/ _sass/ archive.html Gemfile index.html UNLICENSE.txt
- 使用命令终端导航到主题的本地目录,然后运行
bundler install
,安装了一系列所需的 gem:
C:\Users\myuser\contrast-master>bundler install
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Fetching rexml 3.4.1
Fetching rouge 3.30.0
Fetching unicode-display_width 1.8.0
Fetching sassc 2.4.0
Installing rexml 3.4.1
Installing unicode-display_width 1.8.0
Installing rouge 3.30.0
Fetching terminal-table 2.0.0
Installing sassc 2.4.0 with native extensions
Installing terminal-table 2.0.0
Fetching jekyll-sass-converter 2.2.0
Installing jekyll-sass-converter 2.2.0
Fetching jekyll 4.2.2
Installing jekyll 4.2.2
Fetching jekyll-feed 0.17.0
Installing jekyll-feed 0.17.0
Bundle complete! 3 Gemfile dependencies, 30 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
- 尝试使用构建 jekyll 站点
bundle exec jekyll build
,但失败并显示一系列消息:
C:\Users\myuser\contrast-master>bundle exec jekyll build
C:/Ruby33-x64/bin/jekyll:25: warning: csv was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add csv to your Gemfile or gemspec to silence this warning.
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb:22: warning: base64 was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add base64 to your Gemfile or gemspec to silence this warning.
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/liquid-4.0.4/lib/liquid.rb:72: warning: bigdecimal was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add bigdecimal to your Gemfile or gemspec to silence this warning.
------------------------------------------------
Jekyll 4.2.2 Please append `--trace` to the `build` command
for any additional information or backtrace.
------------------------------------------------
C:/Ruby33-x64/lib/ruby/3.3.0/logger.rb:384:in `level': undefined method `[]' for nil (NoMethodError)
@level_override[Fiber.current] || @level
^^^^^^^^^^^^^^^
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/log_adapter.rb:45:in `adjust_verbosity'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/commands/build.rb:27:in `process'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.2.2/exe/jekyll:15:in `<top (required)>'
from C:/Ruby33-x64/bin/jekyll:25:in `load'
from C:/Ruby33-x64/bin/jekyll:25:in `<main>'
有人能帮我看看为什么这无法构建并帮助我修复它吗?
[注意,我想在本地运行它,因为我想要 A)在网站上离线工作,并能够在本地机器的浏览器上进行定期预览,以及 B)访问 _site 文件夹中由 Jekyll 生成的文件,以便将它们直接上传到网络托管服务,而不是让 Jekyll 引擎在 Github Pages、Cloudflare Pages 等上构建网站。]
编辑
按照下面@lmtaq 的回答中的建议,尝试使用较新版本的 jekyll 附加 gem 文件后,我现在收到另一个错误:
$ bundler exec jekyll build
C:/Ruby33-x64/bin/jekyll:25: warning: csv was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add csv to your Gemfile or gemspec to silence this warning.
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/safe_yaml-1.0.5/lib/safe_yaml/load.rb:22: warning: base64 was loaded from the standard library, but will no longer be part of the default gems starting from Ruby 3.4.0.
You can add base64 to your Gemfile or gemspec to silence this warning.
To use retry middleware with Faraday v2.0+, install `faraday-retry` gem
Configuration file: C:/Users/tjb/Desktop/Web Development/contrast-master/_config.yml
Source: C:/Users/tjb/Desktop/Web Development/contrast-master
Destination: C:/Users/tjb/Desktop/Web Development/contrast-master/_site
Incremental build: disabled. Enable with --incremental
Generating...
Jekyll Feed: Generating feed for posts
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
1 │ @import index, font, basic, layout, classes
│ ^^^^^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:9 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
1 │ @import index, font, basic, layout, classes
│ ^^^^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:16 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
1 │ @import index, font, basic, layout, classes
│ ^^^^^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:22 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
1 │ @import index, font, basic, layout, classes
│ ^^^^^^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:29 root stylesheet
Deprecation Warning [import]: Sass @import rules are deprecated and will be removed in Dart Sass 3.0.0.
More info and automated migrator: https://sass-lang.com/d/import
╷
1 │ @import index, font, basic, layout, classes
│ ^^^^^^^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:37 root stylesheet
Error: Expected newline.
╷
8 │ padding: 1.75em calc(40% - 17em)
│ ^
╵
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\index.sass 8:37 @import
C:\Users\tjb\Desktop\Web Development\contrast-master\assets\css\frame.sass 1:9 root stylesheet
Conversion error: Jekyll::Converters::Sass encountered an error while converting 'assets/css/frame.sass':
Expected newline.
------------------------------------------------
Jekyll 4.3.3 Please append `--trace` to the `build` command
for any additional information or backtrace.
------------------------------------------------
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-sass-converter-3.1.0/lib/jekyll/converters/scss.rb:181:in `rescue in convert': Expected newline. (Jekyll::Converters::Scss::SyntaxError)
raise SyntaxError, e.message
^^^^^^^^^^^^^^^^^^^^^^
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-sass-converter-3.1.0/lib/jekyll/converters/scss.rb:162:in `convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:105:in `block in convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `reduce'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:84:in `render_document'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:63:in `run'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:572:in `render_regenerated'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:564:in `block in render_pages'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:563:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:563:in `render_pages'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:211:in `render'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:80:in `process'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:28:in `process_site'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:65:in `build'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:36:in `process'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/exe/jekyll:15:in `<top (required)>'
from C:/Ruby33-x64/bin/jekyll:25:in `load'
from C:/Ruby33-x64/bin/jekyll:25:in `<main>'
C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/sass-embedded-1.86.3-x64-mingw-ucrt/lib/sass/compiler/host.rb:86:in `compile_request': Expected newline. (Sass::CompileError)
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/sass-embedded-1.86.3-x64-mingw-ucrt/lib/sass/compiler.rb:171:in `compile_string'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/sass-embedded-1.86.3-x64-mingw-ucrt/lib/sass/embedded.rb:37:in `compile_string'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-sass-converter-3.1.0/lib/jekyll/converters/scss.rb:163:in `convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:105:in `block in convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `reduce'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:104:in `convert'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:84:in `render_document'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/renderer.rb:63:in `run'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:572:in `render_regenerated'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:564:in `block in render_pages'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:563:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:563:in `render_pages'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:211:in `render'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/site.rb:80:in `process'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:28:in `process_site'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:65:in `build'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:36:in `process'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
from C:/Ruby33-x64/lib/ruby/gems/3.3.0/gems/jekyll-4.3.3/exe/jekyll:15:in `<top (required)>'
from C:/Ruby33-x64/bin/jekyll:25:in `load'
from C:/Ruby33-x64/bin/jekyll:25:in `<main>'