lavas-project / jekyll-pwa

Jekyll plugin for PWA
MIT License
107 stars 19 forks source link

undefined method `+' for nil :NilClass #9

Closed mdelarioja closed 6 years ago

mdelarioja commented 6 years ago

Unfortunately, I am getting an error when I try to run this plugin. Below is the output from --trace.

C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-pwa-plugin-1.0.1/lib/jekyll-pwa-pl
ugin.rb:89:in `block in generate_workbox_precache': undefined method `+' for nil
:NilClass (NoMethodError)
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-pwa-plugin-1.0.1/lib/
jekyll-pwa-plugin.rb:80:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-pwa-plugin-1.0.1/lib/
jekyll-pwa-plugin.rb:80:in `generate_workbox_precache'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-pwa-plugin-1.0.1/lib/
jekyll-pwa-plugin.rb:186:in `block in <module:Jekyll>'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/hook
s.rb:103:in `call'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/hook
s.rb:103:in `block in trigger'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/hook
s.rb:102:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/hook
s.rb:102:in `trigger'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/site
.rb:212:in `write'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/site
.rb:73:in `process'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
and.rb:28:in `process_site'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/build.rb:65:in `build'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/build.rb:36:in `process'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/serve.rb:93:in `block in start'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/serve.rb:93:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/serve.rb:93:in `start'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/lib/jekyll/comm
ands/serve.rb:75:in `block (2 levels) in init_with_program'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y/command.rb:220:in `call'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y/command.rb:220:in `block in execute'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y/command.rb:220:in `each'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y/command.rb:220:in `execute'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y/program.rb:42:in `go'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/mercenary-0.3.6/lib/mercenar
y.rb:19:in `program'
        from C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/jekyll-3.8.2/exe/jekyll:15:i
n `<top (required)>'
        from C:/Ruby22-x64/bin/jekyll:23:in `load'
        from C:/Ruby22-x64/bin/jekyll:23:in `<main>'
parkr commented 6 years ago

This is due to lack of nil checking for site.baseurl throughout the plugin. I would recommend using site.baseurl.to_s in all places.

mdelarioja commented 6 years ago

Thanks a lot, @parkr ; adding 'baseurl: "" ' to my config fixed this issue.

nnamdei commented 6 years ago

@mdelarioja do you mean _config.yml? I have same error using jekyll-theme-so-simple theme

nnamdei commented 6 years ago

@parkr where would this change you are proposing occur in my theme?

parkr commented 6 years ago

@nnamdei In your _config.yml, set baseurl: "".

nnamdei commented 6 years ago

@parkr i tried " " but it didnt give the result i was expecting but ' ' worked instead.

xiaoiver commented 6 years ago

Sorry for my poor Ruby skill, I'll add nil checking for site.baseurl.