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

'no implicit conversion of nil into String' in reader.rb #34

Closed
danrue opened this issue Oct 7, 2019 · 6 comments
Closed

'no implicit conversion of nil into String' in reader.rb #34

danrue opened this issue Oct 7, 2019 · 6 comments

Comments

@danrue
Copy link

danrue commented Oct 7, 2019

I'm not a big ruby guy and so I'm not sure if this is a bug, but it did take me multiple hours to figure out so I thought it is worth documenting and reporting.

While building a jekyll site, I hit the following issue:

root@6c73ddc08899:/code# bundle exec jekyll build
Configuration file: /code/_config.yml
jekyll 3.7.4 | Error:  no implicit conversion of nil into String
root@6c73ddc08899:/code# bundle exec jekyll build --trace
Configuration file: /code/_config.yml
bundler: failed to load command: jekyll (/usr/local/bundle/bin/jekyll)
TypeError: no implicit conversion of nil into String
  /usr/local/bundle/gems/jekyll-data-1.1.0/lib/jekyll-data/reader.rb:10:in `join'
  /usr/local/bundle/gems/jekyll-data-1.1.0/lib/jekyll-data/reader.rb:10:in `initialize'
  /usr/local/bundle/gems/jekyll-data-1.1.0/lib/jekyll-data.rb:50:in `new'
  /usr/local/bundle/gems/jekyll-data-1.1.0/lib/jekyll-data.rb:50:in `block in <top (required)>'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/hooks.rb:103:in `block in trigger'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/hooks.rb:102:in `each'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/hooks.rb:102:in `trigger'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/site.rb:36:in `initialize'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:30:in `new'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:30:in `process'
  /usr/local/bundle/gems/jekyll-3.7.4/lib/jekyll/commands/build.rb:18:in `block (2 levels) in init_with_program'
  /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
  /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
  /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
  /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
  /usr/local/bundle/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
  /usr/local/bundle/gems/jekyll-3.7.4/exe/jekyll:15:in `<top (required)>'
  /usr/local/bundle/bin/jekyll:23:in `load'
  /usr/local/bundle/bin/jekyll:23:in `<top (required)>'
root@6c73ddc08899:/code# 

My Gemfile contained:

group :jekyll_plugins do
  gem "jekyll-data"
end

With such a Gemfile, if certain themes were loaded (themes which do not use jekyll-data?), the traceback seen above is shown during 'jekyll build' or 'jekyll serve'.

Removing jekyll-data from my Gemfile solved the problem, and more than likely it never should have been there in the first place.

However, I would also expect that jekyll-data would handle such a case more gracefully.

Specifically, what it seems is happening is site.theme.data_path is set to nil, and the following line explodes

@theme_data_files = Dir[File.join(site.theme.data_path, "**", "*.{yaml,yml,json,csv,tsv}")]

@ashmaroli
Copy link
Owner

Thank you for filing this report, @danrue.
Your deduction is spot-on. site.theme.data_path is set to nil if Jekyll doesn't find a _data directory in the theme or if it is unable to access the directory.

I didn't place a check to validate site.theme.data_path or silently convert the value to a string because I didn't expect a theme that doesn't bundle data files to load this plugin or recommend loading this plugin.

If the theme you're using doesn't have the _data directory at root and still uses this plugin, you may want to take this issue up to the theme author.

@danrue
Copy link
Author

danrue commented Oct 7, 2019

I understand that this situation shouldn't happen, but as a matter of fact it did for me. Note that the Gemfile that listed this plugin was in my site's folder, not a theme's folder, and so when the site changed from a theme that uses it to a theme that doesn't, it triggered this problem. But it wasn't that easy to find, because the automated build process didn't hit it for some reason.

So I guess it's up to you whether or not it's worth supporting such broken setups - at least a human readable error message would have likely saved me hours.

@ashmaroli
Copy link
Owner

Fair enough. I'll release a patch in a couple of days.
Sorry for the inconvenience caused.

@danrue
Copy link
Author

danrue commented Oct 7, 2019

No problem, and thank you very much. I would just like to save the next person the trouble, which may have already been accomplished by this issue report.

@alexanderadam
Copy link

I was having the same issue with the gem. But the release on GitHub is working, so I guess this fix wasn't released yet?

@ashmaroli
Copy link
Owner

Fix shipped in v1.1.1

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

3 participants