jekyll / jemoji

GitHub-flavored emoji plugin for Jekyll
http://rubygems.org/gems/jemoji
MIT License
557 stars 62 forks source link

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

Closed wessven closed 3 years ago

wessven commented 3 years ago

I'm encountering the error in the title when I try to use jekyll-asciidoc and jemoji together. I first raised this issue with the jekyll-asciidoc developers, but their response was that the error results from the write? method being missing, but that method is not part of the Jekyll API, therefore they should not need to support/implement it.

The error occurs when I enable jemoji plugin on any theme. (The following error mentions the jekyll-mentions plugin, but is essentially the same for jemoji)

  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)

The line of code which causes the exception is

      def emojiable?(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.

DirtyF commented 3 years ago

What version of Jekyll are you using? How can we reproduce this?

jekyllbot commented 3 years ago

This issue has been automatically marked as stale because it has not been commented on for at least two months.

The resources of the Jekyll team are limited, and so we are asking for your help.

If this is a bug and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If this is a feature request, please consider whether it can be accomplished in another way. If it cannot, please elaborate on why it is core to this project and why you feel more than 80% of users would find this beneficial.

This issue will automatically be closed in two months if no further activity occurs. Thank you for all your contributions.

lychronicity commented 3 years ago

@DirtyF, I have just recently encountered this issue as well. I will attempt to answer your questions from your previous post.

What version of Jekyll are you using?

Currently, I am running Jekyll (4.2.0), and Ruby (2.7.0). Additionally, here is a list of all Jekyll gems I'm currently using:

jekyll (4.2.0)
jekyll-asciidoc (3.0.0)
jekyll-feed (0.15.1)
jekyll-paginate (1.1.0)
jekyll-sass-converter (2.1.0)
jekyll-sitemap (1.4.0)
jekyll-watch (2.2.1)
jemoji (0.12.0)

How can we reproduce this?

I ran into this issue whilst adding the jekyll-asciidoc plugin to the jekyll-TeXt-theme. The TeXt theme already includes the jemoji plugin.

I'm running Ubuntu 20.04 (focal).

The simplest way I could reproduce this issue (assuming you have Jekyll and aforementioned gems already installed) is as follows:

  1. Clone the jekyll-TeXt-theme repository.
    git clone https://github.com/kitian616/jekyll-TeXt-theme.git
  2. In the _config.yml scroll to the plugins: section and add - jekyll-asciidoc. It should look like this:
    
    # _config.yml
         ^                ^
         | other settings |

=> Plugins

############################## plugins:

source "https://rubygems.org"

gem "github-pages", group: :jekyll_plugins

group :jekyll_plugins do gem 'jekyll-asciidoc' end

gemspec

4. Add an `.asciidoc` file to the `_posts` folder.  I created a simple test file called `2020-01-20-test-post.asciidoc`.  The file `2020-01-20-test-post.asciidoc` simply contains a single line:

// 2021-01-20-test-post.asciidoc

Hello World!

5. Lastly, from the root of the repo, build the site with Jekyll:

bundle exec jekyll build



## Conclusion
Phew.  😅 

Lastly, since your last comment, there has been some more discussion in this [issue](https://github.com/asciidoctor/jekyll-asciidoc/issues/230) which could be insightful.

I'm not really familiar with Ruby (and new to Jekyll itself!), but hopefully this writeup can assist others with reproducing/solving this issue.  If you have any further questions, feel free to ask; I'll try my best to help out.
wessven commented 3 years ago

My apologies for not replying earlier.

So this does appear to be a bug with jekyll-asciidoc. The Jekyll maintainers had a discussion with the jekyll-asciidoc maintainers and convinced them that this needs to be fixed there.

https://github.com/asciidoctor/jekyll-asciidoc/issues/230

wessven commented 3 years ago

@tfriz343 Would you mind mentioning on the jekyll-asciidoc ticket that you are experiencing this issue as well? https://github.com/asciidoctor/jekyll-asciidoc/issues/230

lychronicity commented 3 years ago

@wessven Sure. Will do. 👍