maximevaillancourt / digital-garden-jekyll-template

Start your own digital garden using this Jekyll template 🌱
https://digital-garden-jekyll-template.netlify.app/
Other
922 stars 732 forks source link

Failure to load plugins in another website #36

Closed xplosionmind closed 3 years ago

xplosionmind commented 3 years ago

If I copy-paste the _plugins folder in my already existing Jekyll website, I get this error message after entering bundle exec jekyll serve --trace --watch:

 Incremental build: disabled. Enable with --incremental
      Generating...
bundler: failed to load command: jekyll (/usr/local/lib/ruby/gems/2.7.0/bin/jekyll)
NoMethodError: undefined method `docs' for nil:NilClass
  /Users/xplosionmind/tommi.space/_plugins/bidirectional_links_generator.rb:7:in `generate'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:191:in `block in generate'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:189:in `each'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:189:in `generate'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/profiler.rb:43:in `block in profile_process'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/profiler.rb:41:in `each'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/profiler.rb:41:in `profile_process'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/site.rb:75:in `process'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:28:in `process_site'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/commands/build.rb:65:in `build'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/commands/build.rb:36:in `process'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `each'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
  /Users/xplosionmind/.gem/ruby/2.7.0/gems/jekyll-4.1.1/exe/jekyll:15:in `<top (required)>'
  /usr/local/lib/ruby/gems/2.7.0/bin/jekyll:23:in `load'
  /usr/local/lib/ruby/gems/2.7.0/bin/jekyll:23:in `<top (required)>'

It appears as a Jekyll problem, since it seems like Ruby can't find the Jekyll Gem, but after removing _plugins, everything gets back to normal.

What have I done wrong?

Thanks a lot. T

maximevaillancourt commented 3 years ago

Hi Tommi! As the error message and the first line of the stack trace show, something is going wrong on the 7th line of the /_plugins/bidirectional_links_generator.rb file in your garden.

This is the line:

https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/becf9f381c86186b832b4cb8624ead3ea0669e23/_plugins/bidirectional_links_generator.rb#L7

As you can see, on this line there's a call to the docs function, but it fails as described by the error message:

NoMethodError: undefined method `docs' for nil:NilClass

This means that whatever docs was called on, in this case site.collections['notes'], is nil (is nothing), so the call fails.

This is likely because you do not have a notes collection in your site. To resolve this, add the following lines to your _config.yml file:

https://github.com/maximevaillancourt/digital-garden-jekyll-template/blob/82995de7460fe54e640e142d95c304a05a664e62/_config.yml#L19-L22

Then, create a _notes/ directory at the root of your project (/Users/xplosionmind/tommi.space/_notes/), and add your Markdown notes in there.

I'll close this as it's not an issue with the template itself, but we can continue discussing here. Let me know if this helps!