Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoMethodError thrown when running jekyll serve --incremental #89

Closed
kerner1000 opened this issue Mar 6, 2018 · 12 comments
Closed

NoMethodError thrown when running jekyll serve --incremental #89

kerner1000 opened this issue Mar 6, 2018 · 12 comments

Comments

@kerner1000
Copy link

@kerner1000 kerner1000 commented Mar 6, 2018

I run bundle exec jekyll serve --incremental and get the following:

Remote Theme: Using theme mmistakes/jekyll-theme-basically-basic
/var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:154:in `relativize_urls': undefined method `gsub!' for nil:NilClass (NoMethodError)
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:115:in `block in process_documents'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:114:in `each'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:114:in `process_documents'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:8:in `block in hook_process'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:7:in `each'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:7:in `hook_process'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:3:in `block in <top (required)>'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/hooks.rb:100:in `block in trigger'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/hooks.rb:99:in `each'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/hooks.rb:99:in `trigger'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:195:in `render'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/site.rb:73:in `process'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:86:in `process_active_language'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:70:in `process_language'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:30:in `block (2 levels) in process'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:29:in `fork'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:29:in `block in process'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:28:in `each'
	from /var/lib/gems/2.3.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:28:in `process'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/command.rb:28:in `process_site'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/commands/build.rb:65:in `build'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/commands/build.rb:36:in `process'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/commands/serve.rb:42:in `block (3 levels) in init_with_program'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/commands/serve.rb:42:in `each'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/lib/jekyll/commands/serve.rb:42:in `block (2 levels) in init_with_program'
	from /var/lib/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
	from /var/lib/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
	from /var/lib/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
	from /var/lib/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
	from /var/lib/gems/2.3.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
	from /var/lib/gems/2.3.0/gems/jekyll-3.6.2/exe/jekyll:15:in `<top (required)>'
	from /usr/local/bin/jekyll:22:in `load'
	from /usr/local/bin/jekyll:22:in `<main>'
                    done in 4.619 seconds.
@untra
Copy link
Owner

@untra untra commented Mar 6, 2018

hmm... with the incremental documents may not have a defined output at the time the hook gets called.

The error is being thrown from here. Relativize urls is being called on a document with a null output. Document output's should not be null when this hook is called.

Any chance your jekyll project is accessible and on github? I'd be happy to clone it down and debug it further.

@kerner1000
Copy link
Author

@kerner1000 kerner1000 commented Mar 6, 2018

Yes, sure, many thanks!
https://kerner1000.github.io/

@untra
Copy link
Owner

@untra untra commented Mar 8, 2018

So this is going to be embarrassing to admit... I haven't done ruby development in awhile, and I have a new computer. I've been meaning to get my ruby environment setup, so I figured I'd get my dev environment setup quickly so I could debug your project.

At this point I've spent four hours trying to get bundle install to work 😨 I'm getting rolled by nokogiri, which is needed by jekyll to parse html / xml files. The damn thing refuses to install at all and I'm going insane here. I don't know what changed in the past few months of ruby development, but my ability to iterate quickly is currently gone 😞 I'll try again later this week, but I'm currently stuck at the moment.

If you have suggestions on good ruby development setups, I could use the advice.

@untra
Copy link
Owner

@untra untra commented Mar 8, 2018

Are you seeing the NoMethodError when you run bundle exec jekyll serve? or does it only show up with the --incremental flag enabled?

@kerner1000
Copy link
Author

@kerner1000 kerner1000 commented Mar 8, 2018

😃 no worries, its working anyways. It happens only with --incremental option.
EDIT: cannot reproduce anymore.. 🙈

@hvoigt
Copy link

@hvoigt hvoigt commented Sep 26, 2018

Just had this same issue after installing polyglot.

jekyll serve --incremental

/home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:154:in `relativize_urls': undefined method `gsub!' for nil:NilClass (NoMethodError)
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:115:in `block in process_documents'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:114:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:114:in `process_documents'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:8:in `block in hook_process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:7:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:7:in `hook_process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/hooks/process.rb:3:in `block in <top (required)>'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/hooks.rb:103:in `block in trigger'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/hooks.rb:102:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/hooks.rb:102:in `trigger'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/site.rb:194:in `render'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/site.rb:71:in `process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:86:in `process_active_language'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:70:in `process_language'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:30:in `block (2 levels) in process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:29:in `fork'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:29:in `block in process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:28:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-polyglot-1.3.1/lib/jekyll/polyglot/patches/jekyll/site.rb:28:in `process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/command.rb:28:in `process_site'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/build.rb:65:in `build'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/build.rb:36:in `process'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `block in start'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:93:in `start'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
	from /home/hvoigt/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/jekyll-3.8.4/exe/jekyll:15:in `<top (required)>'
	from /home/hvoigt/.rbenv/versions/2.4.0/bin/jekyll:22:in `load'
	from /home/hvoigt/.rbenv/versions/2.4.0/bin/jekyll:22:in `<main>'
                    done in 0.113 seconds.

Once I ran just jekyll serve without the --incremental option the issue dissappeared and now even with --incremental it seems to work fine. Not sure what is cached where, but even a clean repository (git clean -xfd) does not help to have it resurface.

@MPJHorner
Copy link

@MPJHorner MPJHorner commented Feb 22, 2019

Had exactly the same error as you, only just starting using --incremental few hours later I start seeing this error.

However, removing --incremental removed the problem, interestingly, if I add it back - it still isn't erroring...

However, when I run doctor I get this notification.

bundle exec jekyll doctor
Configuration file: /Users/User/Documents/GitHub/myApplication/_config.yml
jekyll 3.8.5 | Error:  undefined method `each' for nil:NilClass

Not sure if relate d(or how to fix this!

@cmcnicholas
Copy link

@cmcnicholas cmcnicholas commented Mar 12, 2020

same issue with 4.0.0 of Jekyll

@alexanderadam
Copy link
Contributor

@alexanderadam alexanderadam commented Jul 7, 2020

I can reproduce it with any of my Jekyll projects.
Simply add incremental: true to _config.yml and let the games begin.

Would in site.rb an early return in case of nil output do any harm?

For instance:

def relativize_urls(doc, regex)
  return if doc.output.nil?

  doc.output.gsub!(regex, "href=\"#{@baseurl}/#{@active_lang}/" + '\1"')
end

def relativize_absolute_urls(doc, regex, url)
  return if doc.output.nil?

  doc.output.gsub!(regex, "href=\"#{url}#{@baseurl}/#{@active_lang}/" + '\1"')
end

@untra
Copy link
Owner

@untra untra commented Jul 7, 2020

yeah, this is a bug with incremental builds. Incremental builds use existing cached content that isn't available on the language forks for each build, when the site is fresh. This is a bug I keep punting on.

It has a workaround: Just run one jekyll build without incremental, and the languages from cached pages will be present. I know how necessary --incremental is for faster builds, especially on larger sites. one standard build will get it going I believe.

-sam

@untra untra changed the title NoMethodError NoMethodError thrown when running jekyll serve --incremental Jul 19, 2020
@untra
Copy link
Owner

@untra untra commented Jul 19, 2020

@alexanderadam with your contribution merged in I cut a minor release. would you please try out version 1.3.3 and confirm noMethodError is still thrown on Document.output.nil , and when running with incremental jekyll builds?

@alexanderadam
Copy link
Contributor

@alexanderadam alexanderadam commented Jul 20, 2020

@untra I just tested it and this error is fixed with 1.3.3. Thank you! 👍

I don't believe that this was the only thing necessary for incremental support, but it fixed at least this little error. 😉

@untra untra closed this as completed Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants