{"action":"created","issue":{"url":"https://api.github.com/repos/bundler/bundler/issues/4973","repository_url":"https://api.github.com/repos/bundler/bundler","labels_url":"https://api.github.com/repos/bundler/bundler/issues/4973/labels{/name}","comments_url":"https://api.github.com/repos/bundler/bundler/issues/4973/comments","events_url":"https://api.github.com/repos/bundler/bundler/issues/4973/events","html_url":"https://github.com/bundler/bundler/pull/4973","id":176505136,"number":4973,"title":"Bypass recursive RubyGems require","user":{"login":"aycabta","id":1404325,"avatar_url":"https://avatars.githubusercontent.com/u/1404325?v=3","gravatar_id":"","url":"https://api.github.com/users/aycabta","html_url":"https://github.com/aycabta","followers_url":"https://api.github.com/users/aycabta/followers","following_url":"https://api.github.com/users/aycabta/following{/other_user}","gists_url":"https://api.github.com/users/aycabta/gists{/gist_id}","starred_url":"https://api.github.com/users/aycabta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aycabta/subscriptions","organizations_url":"https://api.github.com/users/aycabta/orgs","repos_url":"https://api.github.com/users/aycabta/repos","events_url":"https://api.github.com/users/aycabta/events{/privacy}","received_events_url":"https://api.github.com/users/aycabta/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-12T22:51:38Z","updated_at":"2016-09-13T07:48:55Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bundler/bundler/pulls/4973","html_url":"https://github.com/bundler/bundler/pull/4973","diff_url":"https://github.com/bundler/bundler/pull/4973.diff","patch_url":"https://github.com/bundler/bundler/pull/4973.patch"},"body":"I fixed a bug that [I reported for Rake test problem](https://github.com/ruby/rake/pull/161#issuecomment-246211119).\r\n\r\nFirst, `Bundler::Plugin` uses cascading `autoload` for `Bundler::Plugin::API` and `Bundler::Plugin::API::Source`.\r\n\r\nSecondly, Bundler uses monkey patch for RubyGems loading logic, thus [`Gem::Specification#full_gem_path`](https://github.com/bundler/bundler/blob/34404bb32945429ffedd484f8f3447529b3b33f4/lib/bundler/rubygems_ext.rb#L44-L50) is overridden.\r\n\r\nNext, if a module is loaded by `require` in RubyGems with Bundler's monkey patch, the `Gem::Specification#full_gem_path` that uses `Bundler::Plugin::API::Source` is called in it. But [`bundler/plugin/api/source` uses `require` before `Bundler::Plugin::API::Source` is defined](https://github.com/bundler/bundler/blob/695db9a169294ec0c6fef3c14ef0f0ac1f6cc65c/lib/bundler/plugin/api/source.rb#L2). RubyGems loading logic runs again by the `require`. `Bundler::Plugin::API::Source` is not defined yet. `Gem::Specification#full_gem_path` is called again, and it uses `Bundler::Plugin::API::Source`. The `autoload` is skipped after 2nd call. So exception is occurred.\r\n\r\n> NameError: uninitialized constant Bundler::Plugin::API::Source\r\n\r\nThis Pull Request bypasses the recursive RubyGems require."},"comment":{"url":"https://api.github.com/repos/bundler/bundler/issues/comments/246602717","html_url":"https://github.com/bundler/bundler/pull/4973#issuecomment-246602717","issue_url":"https://api.github.com/repos/bundler/bundler/issues/4973","id":246602717,"user":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T07:48:55Z","updated_at":"2016-09-13T07:48:55Z","body":"If this fixes a bug, could you see if it's possible to add test coverage? Thanks!"}}
{"actor":{"display_login":"segiddins"}}