{"action":"closed","issue":{"url":"https://api.github.com/repos/jekyll/jekyll/issues/5104","repository_url":"https://api.github.com/repos/jekyll/jekyll","labels_url":"https://api.github.com/repos/jekyll/jekyll/issues/5104/labels{/name}","comments_url":"https://api.github.com/repos/jekyll/jekyll/issues/5104/comments","events_url":"https://api.github.com/repos/jekyll/jekyll/issues/5104/events","html_url":"https://github.com/jekyll/jekyll/issues/5104","id":165660801,"number":5104,"title":"Site.render() swallows all Errno::ENOENT exceptions, leading to silent build failures","user":{"login":"JoshRosen","id":50748,"avatar_url":"https://avatars.githubusercontent.com/u/50748?v=3","gravatar_id":"","url":"https://api.github.com/users/JoshRosen","html_url":"https://github.com/JoshRosen","followers_url":"https://api.github.com/users/JoshRosen/followers","following_url":"https://api.github.com/users/JoshRosen/following{/other_user}","gists_url":"https://api.github.com/users/JoshRosen/gists{/gist_id}","starred_url":"https://api.github.com/users/JoshRosen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JoshRosen/subscriptions","organizations_url":"https://api.github.com/users/JoshRosen/orgs","repos_url":"https://api.github.com/users/JoshRosen/repos","events_url":"https://api.github.com/users/JoshRosen/events{/privacy}","received_events_url":"https://api.github.com/users/JoshRosen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/jekyll/jekyll/labels/has-pull-request","name":"has-pull-request","color":"fbca04"},{"url":"https://api.github.com/repos/jekyll/jekyll/labels/ux","name":"ux","color":"006b75"}],"state":"closed","locked":false,"assignee":{"login":"pathawks","id":251545,"avatar_url":"https://avatars.githubusercontent.com/u/251545?v=3","gravatar_id":"","url":"https://api.github.com/users/pathawks","html_url":"https://github.com/pathawks","followers_url":"https://api.github.com/users/pathawks/followers","following_url":"https://api.github.com/users/pathawks/following{/other_user}","gists_url":"https://api.github.com/users/pathawks/gists{/gist_id}","starred_url":"https://api.github.com/users/pathawks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pathawks/subscriptions","organizations_url":"https://api.github.com/users/pathawks/orgs","repos_url":"https://api.github.com/users/pathawks/repos","events_url":"https://api.github.com/users/pathawks/events{/privacy}","received_events_url":"https://api.github.com/users/pathawks/received_events","type":"User","site_admin":false},"assignees":[{"login":"pathawks","id":251545,"avatar_url":"https://avatars.githubusercontent.com/u/251545?v=3","gravatar_id":"","url":"https://api.github.com/users/pathawks","html_url":"https://github.com/pathawks","followers_url":"https://api.github.com/users/pathawks/followers","following_url":"https://api.github.com/users/pathawks/following{/other_user}","gists_url":"https://api.github.com/users/pathawks/gists{/gist_id}","starred_url":"https://api.github.com/users/pathawks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pathawks/subscriptions","organizations_url":"https://api.github.com/users/pathawks/orgs","repos_url":"https://api.github.com/users/pathawks/repos","events_url":"https://api.github.com/users/pathawks/events{/privacy}","received_events_url":"https://api.github.com/users/pathawks/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2016-07-14T21:16:26Z","updated_at":"2016-10-20T04:24:11Z","closed_at":"2016-10-20T04:24:11Z","body":"- [x] I believe this to be a bug, not a question about using Jekyll.\r\n- [x] I Updated to the latest Jekyll (or) if on Github Pages to the latest `github-pages`\r\n- [x] I Read the CONTRIBUTION file at https://jekyllrb.com/docs/contributing/\r\n- [ ] This is a feature request.\r\n\r\n---\r\n\r\n- [x] I am on (or have tested on) ***macOS*** 10+\r\n- [ ] I am on (or have tested on) ***Debian/Ubuntu*** GNU/Linux\r\n- [ ] I am on (or have tested on) ***Fedora*** GNU/Linux\r\n- [ ] I am on (or have tested on) ***Arch*** GNU/Linux\r\n- [x] I am on (or have tested on) ***Other*** GNU/Linux\r\n- [ ] I am on (or have tested on) ***Windows*** 10+\r\n\r\n---\r\n\r\n- [ ] I was trying to install.\r\n- [ ] There is a broken Plugin API.\r\n- [ ] I had an error on Github Pages, and I have not tested locally.\r\n- [ ] I had an error on Github Pages, and Github Support said it was a Jekyll Bug.\r\n- [ ] I had an error on Github Pages and I did not test it locally.\r\n- [x] I was trying to build.\r\n- [ ] It was another bug.\r\n\r\n## My Reproduction Steps\r\n\r\nCreate a new site using `jekyll new my-test-site`. Then create a custom Liquid tag which only throws missing file errors when run:\r\n\r\n```ruby\r\n# in _plugins/mytag.rb\r\nrequire 'liquid'\r\n\r\nmodule Jekyll\r\n  class MyCustomTag < Liquid::Tag\r\n\r\n    def initialize(tag_name, argument, tokens)\r\n      super\r\n    end\r\n\r\n    def render(context)\r\n      puts \"Rendering my_tag\"\r\n      File.open(\"/some/file/that/does/not/exist\").read.encode(\"UTF-8\")\r\n    end\r\n  end\r\nend\r\n\r\nLiquid::Template.register_tag('my_custom_tag', Jekyll::MyCustomTag)\r\n```\r\n\r\nNext, update a post to use this tag:\r\n\r\n```md\r\n{% my_custom_tag some_argument %}\r\n```\r\n\r\nFinally, render the site with `jekyll build`.\r\n\r\n## The Output I Wanted\r\n\r\nI wanted Jekyll to exit with a non-zero exit code because the uncaught exception in my tag prevents the site from rendering properly.\r\n\r\nWhat _actually_ happens is that the error is logged and Jekyll reports that the site was successfully built, but the actual `_site/` output is missing several posts, including the page with the bad tag _and_ other pages:\r\n\r\n```\r\nConfiguration file: /private/tmp/error-handling-bug/_config.yml\r\n            Source: /private/tmp/error-handling-bug\r\n       Destination: /private/tmp/error-handling-bug/_site\r\n Incremental build: disabled. Enable with --incremental\r\n      Generating...\r\nRendering my_tag\r\n  Liquid Exception: No such file or directory - /some/file/that/does/not/exist in /private/tmp/error-handling-bug/_posts/2016-07-14-welcome-to-jekyll.markdown\r\n                    done in 0.031 seconds.\r\n Auto-regeneration: disabled. Use --watch to enable.\r\n```\r\n\r\n## Cause of bug\r\n\r\nWhen Ruby's `File.open()` fails due to a missing file, it throws `Errno::ENOENT`. This exception bubbles up to Jekyll's `Site.render()` method, [**where it is silently ignored**](https://github.com/jekyll/jekyll/blob/8a3ea59141d721b09a762d7ae26e677b173bfcfa/lib/jekyll/site.rb#L192):\r\n\r\n```\r\n    rescue Errno::ENOENT\r\n      # ignore missing layout dir\r\n    end\r\n```\r\n\r\nThis is sloppy error-handling; at a minimum, the `rescue` statement should log a warning, but ideally the \"ignore missing layout dir\" logic would be scoped more narrowly so that it doesn't catch and ignore `Errno::ENOENT` exceptions thrown by other parts of the page rendering code."}}
{"actor":{"display_login":"jekyllbot"}}