jekyll-asciidoc: undefined method `write?' for #excerpt>:Jekyll::AsciiDoc::Excerpt (NoMethodError)

I’m encountering the error in the title when I try to use jekyll-asciidoc and it seemingly calls into a hook of a plugin (but not always).

In the jekyll-theme-clean-blog theme, without additional plugins, the following piece of code succeeds:

<h3 class="post-subtitle">{{ post.excerpt | strip_html | truncatewords: 15 }}</h3>

But if I enable, say, the jekyll-mentions or jekyll-jemoji plugin, I get an error such as:

  Liquid Exception: undefined method `write?' for <Excerpt: /my-first-post#excerpt>:Jekyll::AsciiDoc::Excerpt in feed.xml
Traceback (most recent call last):
        67: from /usr/gem/bin/jekyll:23:in `<main>'
        66: from /usr/gem/bin/jekyll:23:in `load'
        65: from /usr/gem/gems/jekyll-3.8.6/exe/jekyll:15:in `<top (required)>'
        64: from /usr/gem/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        63: from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        62: from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        61: from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        60: from /usr/gem/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        59: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
        58: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `start'
        57: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `each'
        56: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/serve.rb:93:in `block in start'
        55: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:36:in `process'
        54: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/commands/build.rb:65:in `build'
        53: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/command.rb:28:in `process_site'
        52: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:71:in `process'
        51: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:192:in `render'
        50: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:471:in `render_pages'
        49: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:471:in `each'
        48: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:472:in `block in render_pages'
        47: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/site.rb:479:in `render_regenerated'
        46: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:62:in `run'
        45: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:79:in `render_document'
        44: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/renderer.rb:126:in `render_liquid'
        43: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:28:in `render!'
        42: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:49:in `measure_time'
        41: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:29:in `block in render!'
        40: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:42:in `measure_bytes'
        39: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/liquid_renderer/file.rb:30:in `block (2 levels) in render!'
        38: from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:220:in `render!'
        37: from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:207:in `render'
        36: from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:242:in `with_profiling'
        35: from /usr/gem/gems/liquid-4.0.3/lib/liquid/template.rb:208:in `block in render'
        34: from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
        33: from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
        32: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:79:in `render'
        31: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:150:in `render_segment'
        30: from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
        29: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `block in render_segment'
        28: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:158:in `each'
        27: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/for.rb:160:in `block (2 levels) in render_segment'
        26: from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:82:in `render'
        25: from /usr/gem/gems/liquid-4.0.3/lib/liquid/block_body.rb:103:in `render_node_to_output'
        24: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/if.rb:43:in `render'
        23: from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:123:in `stack'
        22: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/if.rb:44:in `block in render'
        21: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/if.rb:44:in `each'
        20: from /usr/gem/gems/liquid-4.0.3/lib/liquid/tags/if.rb:45:in `block (2 levels) in render'
        19: from /usr/gem/gems/liquid-4.0.3/lib/liquid/condition.rb:46:in `evaluate'
        18: from /usr/gem/gems/liquid-4.0.3/lib/liquid/condition.rb:46:in `loop'
        17: from /usr/gem/gems/liquid-4.0.3/lib/liquid/condition.rb:47:in `block in evaluate'
        16: from /usr/gem/gems/liquid-4.0.3/lib/liquid/condition.rb:114:in `interpret_condition'
        15: from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:159:in `evaluate'
        14: from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `evaluate'
        13: from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:38:in `each_index'
        12: from /usr/gem/gems/liquid-4.0.3/lib/liquid/variable_lookup.rb:48:in `block in evaluate'
        11: from /usr/gem/gems/liquid-4.0.3/lib/liquid/context.rb:197:in `lookup_and_evaluate'
        10: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/drops/drop.rb:52:in `[]'
         9: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/drops/drop.rb:52:in `public_send'
         8: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/drops/document_drop.rb:24:in `excerpt'
         7: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/excerpt.rb:70:in `to_s'
         6: from /usr/gem/gems/jekyll-asciidoc-3.0.0/lib/jekyll-asciidoc/excerpt.rb:31:in `output'
         5: from /usr/gem/gems/jekyll-asciidoc-3.0.0/lib/jekyll-asciidoc/excerpt.rb:45:in `trigger_hooks'
         4: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/hooks.rb:102:in `trigger'
         3: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/hooks.rb:102:in `each'
         2: from /usr/gem/gems/jekyll-3.8.6/lib/jekyll/hooks.rb:103:in `block in trigger'
         1: from /usr/gem/gems/jekyll-mentions-1.2.0/lib/jekyll-mentions.rb:101:in `block in <top (required)>'
/usr/gem/gems/jekyll-mentions-1.2.0/lib/jekyll-mentions.rb:82:in `mentionable?': undefined method `write?' for <Excerpt: /my-first-post#excerpt>:Jekyll::AsciiDoc::Excerpt (NoMethodError)

In both the jekyll-mentions and jekyll-jemoji plugins, the line of code which causes the exception is

      def emojiable?(doc)   # or def mentionable?(doc)
        (doc.is_a?(Jekyll::Page) || doc.write?) &&   # <---- line with error
          doc.output_ext == ".html" || (doc.permalink&.end_with?("/"))
      end

This error occurs both with implicit page-excerpt definitions and where it is inferred from page-excerpt_separator.

If it’s a case of me missing a plugin or some other dependency, then I haven’t been able to find it.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 19 (6 by maintainers)

Commits related to this issue

Most upvoted comments

Update: The page at https://jekyllrb.com/docs/plugins/hooks/ has been improved to better inform developers on how to go about using hooks in their plugins.

@BerkhanEminsoy The fix efc4da2 hasn’t been published via a new release yet. So, you’ll have to point your Gemfile to this repository until then:

gem "jekyll-asciidoc", github: "asciidoctor/jekyll-asciidoc"

Very helpful, thank you! DOH!!!

Sorry for bringing this up again but I’m facing this exact error with jekyll-asciidoc and jemoji. I can see from the commit efc4da2 that jekyll-mentions was added to jekyll-asciidoc.gemspec and spec/fixtures/posts_with_excerpts/_config.yml but I can see no reference to jemoji. Could this be the issue? Then again I probably shouldn’t speculate since I don’t know anything about how jekyll works under the hood.

If it’s needed, my dependency versions are as follows

ruby 3.0.2
jekyll (4.2.0)
jekyll-asciidoc (3.0.0)
jemoji (~> 0.8)

For further info, you may refer to https://jekyllrb.com/docs/plugins/hooks/ Also, from your earlier comment, I understand that it wasn’t clear to you how one could set up custom hooks for custom Jekyll objects. So, I have a tutorial in the works. Will update here once it gets published on the docs site…

Thanks for that input! I’ll study it.

We have the same problem in JUnit Pioneer. I know next to nothing about Ruby and didn’t even try to fix it. Would be nice if someone could take a look. 😺