Error: undefined method `fetch' for true:TrueClass in sitemap.xml

First post here so forgive me if I miss some important details.

I’m trying to use bundle exec jekyll serve to generate my static site, but I keep getting the following error message:

  Liquid Exception: undefined method `fetch' for true:TrueClass in sitemap.xml

I have disabled all plugins, and re-enabled them one by one, and it’s clear that this is being caused by the jekyll-sitemap plugin (as is also evident in the error message).

I try to work around it by simply disabling it, as I don’t think I need it for this tiny blog project (correct me if I’m wrong), but if I disable it, none of my {% for %} loops in Liquid seem to work anymore, as only my index.html gets generated. I can’t see why this is connected to jekyll-sitemap, but I’m very new to Ruby and to Jekyll.

Here’s what I get when I try bundle exec jekyll serve --trace. I’m still not sure I see the real source of the problem.

Configuration file: /Users/user1/projects/jekyll_test_1/_config.yml
            Source: /Users/user1/projects/jekyll_test_1
       Destination: /Users/user1/projects/jekyll_test_1/_site
 Incremental build: disabled. Enable with --incremental
      Generating... 
  Liquid Exception: undefined method `fetch' for true:TrueClass in sitemap.xml
bundler: failed to load command: jekyll (/usr/local/lib/ruby/gems/2.6.0/bin/jekyll)
NoMethodError: undefined method `fetch' for true:TrueClass
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/collection.rb:181:in `write?'
  /usr/local/Cellar/ruby/2.6.5/lib/ruby/2.6.0/forwardable.rb:230:in `output'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/drops/drop.rb:52:in `public_send'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/drops/drop.rb:52:in `[]'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/context.rb:197:in `lookup_and_evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:48:in `block in evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `each_index'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/context.rb:159:in `evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/condition.rb:116:in `interpret_condition'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/condition.rb:47:in `block in evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/condition.rb:46:in `loop'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/condition.rb:46:in `evaluate'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/filters.rb:204:in `block (2 levels) in where_exp'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/filters.rb:202:in `select'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/filters.rb:202:in `block in where_exp'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/filters.rb:201:in `where_exp'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/strainer.rb:56:in `invoke'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/context.rb:86:in `invoke'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:84:in `block in render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `each'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `inject'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/variable.rb:82:in `render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/tags/assign.rb:26:in `render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/block_body.rb:91:in `render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
  /usr/local/lib/ruby/gems/2.6.0/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:126:in `render_liquid'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:79:in `render_document'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/renderer.rb:62:in `run'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:479:in `render_regenerated'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:472:in `block in render_pages'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:471:in `each'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:471:in `render_pages'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:192:in `render'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/site.rb:71:in `process'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/command.rb:28:in `process_site'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/build.rb:65:in `build'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/build.rb:36:in `process'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/serve.rb:93:in `block in start'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/serve.rb:93:in `each'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/serve.rb:93:in `start'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
  /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /usr/local/lib/ruby/gems/2.6.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /usr/local/lib/ruby/gems/2.6.0/gems/jekyll-3.8.5/exe/jekyll:15:in `<top (required)>'
  /usr/local/lib/ruby/gems/2.6.0/bin/jekyll:23:in `load'
  /usr/local/lib/ruby/gems/2.6.0/bin/jekyll:23:in `<top (required)>

Thanks for your time, let me know if there’s anything I can clarify!

it’s possible you have ruby installed more than once, if you look at this line the path is different than all the others. More than one installation of Ruby seems to cause weird issues like yours.

I’m not positive that is your issue, but that would be the first thing I would look at. Try uninstalling ruby, then check the ruby version to see if it is still installed. Then reinstall. I’m not a ruby expert so not sure what all else to do.

1 Like

Good eye! I did not notice that. Gonna uninstall all my versions of ruby (this is my only project using it so I’m not too worried about a fresh environment). I’ll get back to you. :slightly_smiling_face:

Edit: Figured it out thanks to a stackoverflow post I made. I had an error in my _config.yml.

Thanks everyone!