我是 Ruby 新手。运行命令bundle update
时出现错误。这就是我的 Gemfile 的样子:
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "jekyll", "~> 3.8"
gem "github-pages", group: :jekyll_plugins
plugins:
- jekyll-sitemap
- jekyll-paginate
- jekyll-redirect-from
- github-pages
这是我运行bundle update
时遇到的错误:
[!] There was an error parsing `Gemfile`: syntax error, unexpected ':', expecting end-of-input - plugins:
^
. Bundler cannot continue.
# from /home/<user>/Documents/projects/<user>.github.io/Gemfile:10
# -------------------------------------------
#
> plugins:
# - jekyll-sitemap
期待有关如何解决此问题的任何指示。谢谢!
最佳答案
您的 Gemfile 是 Bundler 的 Ruby 文件,它指定您的项目需要的 gem。您在 Gemfile 中编写的 plugins:
部分是 YAML,旨在进入 _config.yml
,而不是 Ruby,因此出现语法错误。
您需要将 Gemfile 的这一部分重写为 Ruby,位于 gem 组 jekyll_plugins
中,以便 Jekyll 知道使用这些 gem 作为插件:
source "https://rubygems.org"
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
gem "jekyll", "~> 3.8"
group :jekyll_plugins do
gem "jekyll-sitemap"
gem "jekyll-paginate"
gem "jekyll-redirect-from"
gem "github-pages"
end
还有其他方法可以做到这一点,listed on the Jekyll documentation ,但我推荐这个。
关于ruby - Gemfile `Bundler cannot continue` 意外 ':' 错误 [Ruby],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59919634/