zerodark
zerodark

Reputation: 131

Gemfile `Bundler cannot continue` unexpected ':' error [Ruby]

I'm new to Ruby. I'm getting an error when I run the command bundle update. This is what my Gemfile looks like:

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

Here's the error I get when I run 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

Looking forward to any pointers on how to fix this problem. Thanks!

Upvotes: 2

Views: 1230

Answers (1)

Aaron Christiansen
Aaron Christiansen

Reputation: 11807

Your Gemfile is a Ruby file for Bundler which specifies the gems your project needs. The plugins: section you've written in your Gemfile is YAML designed to go in _config.yml, not Ruby, hence your syntax error.

You'll need to rewrite this section of your Gemfile into Ruby, in a gem group jekyll_plugins so Jekyll knows to use those gems as plugins:

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

There are other ways of doing this too, listed on the Jekyll documentation, but I'd recommend this one.

Upvotes: 2

Related Questions