{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/29632","repository_url":"https://api.github.com/repos/rails/rails","labels_url":"https://api.github.com/repos/rails/rails/issues/29632/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/29632/comments","events_url":"https://api.github.com/repos/rails/rails/issues/29632/events","html_url":"https://github.com/rails/rails/issues/29632","id":239576557,"number":29632,"title":"When LoadError#path is nil LoadError#is_missing? throws NoMethodError","user":{"login":"nrser","id":207603,"avatar_url":"https://avatars2.githubusercontent.com/u/207603?v=3","gravatar_id":"","url":"https://api.github.com/users/nrser","html_url":"https://github.com/nrser","followers_url":"https://api.github.com/users/nrser/followers","following_url":"https://api.github.com/users/nrser/following{/other_user}","gists_url":"https://api.github.com/users/nrser/gists{/gist_id}","starred_url":"https://api.github.com/users/nrser/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nrser/subscriptions","organizations_url":"https://api.github.com/users/nrser/orgs","repos_url":"https://api.github.com/users/nrser/repos","events_url":"https://api.github.com/users/nrser/events{/privacy}","received_events_url":"https://api.github.com/users/nrser/received_events","type":"User","site_admin":false},"labels":[{"id":107194,"url":"https://api.github.com/repos/rails/rails/labels/activesupport","name":"activesupport","color":"FC9300","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2017-06-29T18:48:52Z","updated_at":"2017-07-05T12:09:10Z","closed_at":null,"body":"It's possible for `LoadError#path` to be `nil` when a mixin included in `ApplicationHelper` is misnamed, resulting in a crash on boot with a none-too-useful error:\r\n\r\n```\r\nweb_1  | ./dev/.bundle/ruby/2.3.0/gems/activesupport-5.1.1/lib/active_support/core_ext/load_error.rb:12:in `is_missing?': undefined method `sub' for nil:NilClass (NoMethodError)\r\nweb_1  | \tfrom ./dev/.bundle/ruby/2.3.0/gems/actionpack-5.1.1/lib/abstract_controller/helpers.rb:189:in `rescue in default_helper_module!'\r\nweb_1  | \tfrom ./dev/.bundle/ruby/2.3.0/gems/actionpack-5.1.1/lib/abstract_controller/helpers.rb:185:in `default_helper_module!'\r\nweb_1  | \tfrom ./dev/.bundle/ruby/2.3.0/gems/actionpack-5.1.1/lib/abstract_controller/helpers.rb:36:in `block in inherited'\r\nweb_1  | \tfrom ./dev/.bundle/ruby/2.3.0/gems/actionpack-5.1.1/lib/abstract_controller/helpers.rb:36:in `class_eval'\r\n...\r\n```\r\n\r\nFull stack trace here:\r\n\r\nhttps://gist.github.com/nrser/f59050d699dbdcb8772a4afcee07be5d\r\n\r\n### Steps to reproduce\r\n\r\nI have several chunks of application-wide helper functionality split out into mixins like:\r\n\r\n```ruby\r\n# app/helpers/helper_mixins/css_helper.rb\r\nmodule HelperMixins\r\n  module CSSHelper\r\n    # ...\r\n  end\r\nend\r\n```\r\n\r\nThey are included in `ApplicationHelper`:\r\n\r\n```ruby\r\nmodule ApplicationHelper  \r\n  include HelperMixins::CSSHelper\r\n  # ...\r\nend\r\n```\r\n\r\nEverything works fine when the names are correct, but when they aren't - say `ApplicationHelper` includes `HelperMixins::CssHelper` by accident - I get a crash on boot with the above stack trace.\r\n\r\nIt's worth noting that i'm using inflections to define a `CSS` acronym, though when messing around it doesn't seem to make a difference.\r\n\r\nThere are actually two `sub` calls on the line in question:\r\n\r\nhttps://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/load_error.rb#L12\r\n\r\nBut I hacked a `puts` in there and confirmed that it's `LoadError#path` that is `nil`.\r\n\r\n### Expected behavior\r\n\r\nThe error message should reflect the problem - missing module, bad file name, etc.\r\n\r\n### Actual behavior\r\n\r\nThe `LoadError#is_missing?` method itself errors, raising a `NoMethodError` that does little to indicate the underlying problem.\r\n\r\n### System configuration\r\n**Rails version**: 5.1.1\r\n\r\n**Ruby version**: 2.3.4\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/313084335","html_url":"https://github.com/rails/rails/issues/29632#issuecomment-313084335","issue_url":"https://api.github.com/repos/rails/rails/issues/29632","id":313084335,"user":{"login":"matthewd","id":1034,"avatar_url":"https://avatars2.githubusercontent.com/u/1034?v=3","gravatar_id":"","url":"https://api.github.com/users/matthewd","html_url":"https://github.com/matthewd","followers_url":"https://api.github.com/users/matthewd/followers","following_url":"https://api.github.com/users/matthewd/following{/other_user}","gists_url":"https://api.github.com/users/matthewd/gists{/gist_id}","starred_url":"https://api.github.com/users/matthewd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/matthewd/subscriptions","organizations_url":"https://api.github.com/users/matthewd/orgs","repos_url":"https://api.github.com/users/matthewd/repos","events_url":"https://api.github.com/users/matthewd/events{/privacy}","received_events_url":"https://api.github.com/users/matthewd/received_events","type":"User","site_admin":false},"created_at":"2017-07-05T12:09:10Z","updated_at":"2017-07-05T12:09:10Z","body":"Yes, please do PR. While modern rubies won't internally raise a LoadError without a `path`, it wasn't *that* long ago that it was normal, so it seems reasonable for us to accomodate 3rd party libraries that haven't caught up with the times. (Though correspondingly, *we* shouldn't be generating such half-formed exceptions.)\r\n\r\nI don't think it should raise, though: just return false. This method is already here for us to attempt to friendlify an error message; if the `path` is missing, the safest choice would seem to be to assume it's not the error we're looking for, and let it proceed as is.\r\n\r\nIt'd also probably be worthwhile identifying which library is seemingly interfering, to help them modernize.. but as you say, handling it on our side is independent of that."}}
{"actor":{"display_login":"matthewd"}}