【问题标题】:Gemfile `Bundler cannot continue` unexpected ':' error [Ruby]Gemfile`Bundler cannot continue`意外':'错误[Ruby]
【发布时间】:2020-01-26 15:09:24
【问题描述】:

我是 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

期待有关如何解决此问题的任何指示。谢谢!

【问题讨论】:

  • 这个文件应该是有效的ruby。你文件的尾部是yaml。我很确定互联网上有很多 jekyll Gemfile 的例子。

标签: ruby jekyll bundler


【解决方案1】:

您的 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,但我会推荐这个。

【讨论】:

    猜你喜欢
    • 2019-03-23
    • 1970-01-01
    • 2013-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多