Open jfredrickson5 opened 8 years ago
Looking into this...not really clear where the error is actually coming from. Will continue poking at it.
$ bundle exec jekyll build -t
Configuration file: /Users/aidanfeldman/dev/18F/search-test/_config.yml
Source: /Users/aidanfeldman/dev/18F/search-test
Destination: /Users/aidanfeldman/dev/18F/search-test/_site
Incremental build: disabled. Enable with --incremental
Generating...
jekyll_pages_api_search: checking for Node.js: v6.0.0
Liquid Exception: undefined method `start_with?' for nil:NilClass in index.html
/Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll.rb:161:in `sanitized_path': undefined method `start_with?' for nil:NilClass (NoMethodError)
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:369:in `block in in_source_dir'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:368:in `each'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:368:in `reduce'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:368:in `in_source_dir'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/liquid_renderer.rb:17:in `file'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/renderer.rb:109:in `render_liquid'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/renderer.rb:157:in `place_in_layouts'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/renderer.rb:71:in `run'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:458:in `block in render_pages'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:456:in `each'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:456:in `render_pages'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:191:in `render'
from /Users/aidanfeldman/dev/18F/jekyll_pages_api/lib/jekyll/site.rb:9:in `render'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/site.rb:69:in `process'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/command.rb:26:in `process_site'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/commands/build.rb:63:in `build'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/commands/build.rb:34:in `process'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/lib/jekyll/commands/build.rb:16:in `block (2 levels) in init_with_program'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/gems/jekyll-3.2.1/exe/jekyll:13:in `<top (required)>'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/bin/jekyll:22:in `load'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/bin/jekyll:22:in `<main>'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `eval'
from /Users/aidanfeldman/.rvm/gems/ruby-2.3.1/bin/ruby_executable_hooks:15:in `<main>'
Not sure if/why it would make a difference, but do you get the same thing on serve
?
Yup, same issue with serve
.
Also, build -V
presents some interesting info. It seems to process index.html twice. If I remove jekyll_pages_api_search
, Jekyll only processes index.html once (after feed.xml
and before css/main.scss
).
$ bundle exec jekyll build -V
Logging at level: debug
Configuration file: /home/jf/search-test/_config.yml
Requiring: kramdown
Source: /home/jf/search-test
Destination: /home/jf/search-test/_site
Incremental build: disabled. Enable with --incremental
Generating...
Reading: _posts/2016-10-05-welcome-to-jekyll.markdown
jekyll_pages_api_search: checking for Node.js: v6.7.0
Generating: JekyllPagesApiSearch::Generator finished in 0.002615979 seconds.
Rendering: _posts/2016-10-05-welcome-to-jekyll.markdown
Pre-Render Hooks: _posts/2016-10-05-welcome-to-jekyll.markdown
Rendering Liquid: _posts/2016-10-05-welcome-to-jekyll.markdown
Requiring: rouge
Rendering Markup: _posts/2016-10-05-welcome-to-jekyll.markdown
Requiring: kramdown
Rendering Layout: _posts/2016-10-05-welcome-to-jekyll.markdown
Rendering: _posts/2016-10-05-welcome-to-jekyll.markdown
Pre-Render Hooks: _posts/2016-10-05-welcome-to-jekyll.markdown
Rendering Liquid: _posts/2016-10-05-welcome-to-jekyll.markdown
Rendering Markup: _posts/2016-10-05-welcome-to-jekyll.markdown
Rendering: about.md
Pre-Render Hooks: about.md
Rendering Liquid: about.md
Rendering Markup: about.md
Rendering Layout: about.md
Rendering: feed.xml
Pre-Render Hooks: feed.xml
Rendering Liquid: feed.xml
Rendering Markup: feed.xml
Rendering Layout: feed.xml
Rendering: index.html
Pre-Render Hooks: index.html
Rendering Liquid: index.html
Rendering Markup: index.html
Rendering Layout: index.html
Rendering: css/main.scss
Pre-Render Hooks: css/main.scss
Rendering Liquid: css/main.scss
Rendering Markup: css/main.scss
Rendering: index.html
Pre-Render Hooks: index.html
Rendering Liquid: index.html
Rendering Markup: index.html
Rendering Layout: index.html
Liquid Exception: undefined method `start_with?' for nil:NilClass in index.html
jekyll 3.2.1 | Error: undefined method `start_with?' for nil:NilClass
Hmm, shot in the dark here, but this seems to solve many unexplainable Jekyll plugin problems: Try adding a block like this to your _config.yml
exclude:
vendor
node_modules
Here's how we do it on 18f.gsa.gov (where we have this search working).
Nope, no luck with the exclude.
Hey all:
Didn't see the repro codebase at the top of the issue, so I made one as well: https://github.com/jwworth/jekyll_pages_api_search_issue_9
It contains a WIP branch called 'no-error' that avoids the error, by uncommenting this line: https://github.com/jwworth/jekyll_pages_api_search_issue_9/blob/377d7b0cf92ba222e4f345da3c17b36ed0317554/_config.yml#L39
My repro command was jekyll build
; running this command with -t
shows the full backtrace and was helpful.
I think this line of code in Jekyll is the source of the problems: https://github.com/jekyll/jekyll/blob/master/lib/jekyll.rb#L161
The method is called multiple times from here: https://github.com/jekyll/jekyll/blob/master/lib/jekyll/site.rb#L369
path
is nil
on files in the root directory, so this method is going to be the source of a lot of errors. This isn't a complete solution, but hopefully it is helpful.
I have exactelly the same error. Did someone solved it ? jekyll 3.3.0 If i remove all this part from the tutorial, the build function works ! And i say all, not just one part.
index_fields
should correspond to a field generated byboost
member as a signalindex_fields: title: boost: 10 tags: boost: 10 url: boost: 5 body:
browserify: source: js/my-search.js target: js/my-search-bundle.js
So i think the problem is in the ruby pluqin for jekyll.
Just ran into this same problem with @maya as well; there seems to have been a change in https://github.com/jekyll/jekyll/compare/v3.1.6...v3.2.0 that broke the plugin. Will try and investigate when I can, but pull requests are welcome 😁 We may also need to start testing against multiple versions of Jekyll... https://github.com/18F/jekyll_pages_api_search/issues/39
In other words, a (temporary) workaround is to set gem 'jekyll', '~> 3.1.0'
in your Gemfile
.
Started on a fix - submitted at https://github.com/18F/jekyll_pages_api_search/pull/41.
It seems to process index.html twice
I believe the second one is the search results page.
@afeld huh, is that why AccessLint is posting errors twice https://github.com/18F/accessibility/issues/170?
👋 I'm looking at updating the version of Jekyll that guides-style
uses. Was this ever resolved, or should I cap the version at 3.1?
I don't know that it was fully resolved but capping the version seems to be a solution. If you're on Federalist, though, you might run into difficulty. We use Jekyll 3.3.0 on 18f.gsa.gov and search is working.
I suppose it's possible there was a problem with 3.2 that broke search and something in 3.3 that fixed it?
Just updated the test case to try Jekyll 3.3.0 and then the latest release, 3.4.3. I'm still seeing the issue on both versions, running locally. :(
Related issue: https://github.com/jekyll/jekyll/issues/5145#issuecomment-235990671
In short, it seems this is a bug that Gem-based themes encounter with new versions of Jekyll, manifested as @jwworth noted above. The Jekyll issue he noted is triggered when the skip_index
option in the config is set to false
. I'm investigating whether there's a way we can provide a default path for Jekyll to use when it tries and fails to resolve paths correctly. Barring that, I think we're going to have to include a disclaimer here that you must use Jekyll 3.1. :-(
EDIT: Forgot to add: The issue I linked to is for symlinked gems (and has a fix associated with it), but is indicative of what I'm seeing locally.
Just noticed: The jekyll_pages_api
gem, on which this gem relies, monkey-patches Jekyll. Running this gem errors on that line of that gem -- it's the last line here (I cut off the rest of the trace for clarity, and because it's the same as what was already pasted):
jekyll_pages_api_search: checking for Node.js: v7.4.0
Liquid Exception: undefined method `start_with?' for nil:NilClass in pages/alternativeversions.md
bundler: failed to load command: jekyll (/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bin/jekyll)
NoMethodError: undefined method `start_with?' for nil:NilClass
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll.rb:165:in `sanitized_path'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:365:in `block in in_source_dir'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:364:in `each'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:364:in `reduce'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:364:in `in_source_dir'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/liquid_renderer.rb:17:in `file'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/renderer.rb:129:in `render_liquid'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/renderer.rb:177:in `place_in_layouts'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/renderer.rb:91:in `run'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:463:in `block in render_pages'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:461:in `each'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:461:in `render_pages'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll-3.4.3/lib/jekyll/site.rb:191:in `render'
/Users/heatherbattaglia/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/jekyll_pages_api-0.1.6/lib/jekyll/site.rb:9:in `render'
...
Um, so I cribbed from the monkeypatching of Jekyll that @hbillings mentioned above, and used the same technique to monkeypatch Jekyll again to work around the exception that's being thrown. You can view the source but it's short enough that I can just paste it in here:
module Jekyll
class << self
alias_method :orig_sanitized_path, :sanitized_path
# This is a horrible workaround for:
# https://github.com/18F/jekyll_pages_api_search/issues/37
def sanitized_path(base_directory, questionable_path)
if questionable_path.nil?
questionable_path = ''
end
orig_sanitized_path base_directory, questionable_path
end
end
end
Just plop that into a .rb
file in your _plugins
directory and, um, it seems to make things work. That said, I'm a noob at Ruby, Jekyll, lunr.js, and any other technologies involved in this stack, so caveat emptor.
Rather than trying to fix this directly, I think #28 is the cleaner way to go, and would sidestep the issue.
I think I am stuck here too. Any fix?
Added and configured the plugin as described in the README. I get this error when running
bundle exec jekyll build
afterwards.Jekyll 3.2.1 Ruby 2.3.1 Node.js 6.7.0
Minimal test case here, it is a fresh Jekyll site with the jekyll_pages_api_search plugin installed: https://github.com/jfredrickson5/search-test
Site builds and renders normally if I remove the plugin from
_config.yml
.