{"action":"created","issue":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/1143","labels_url":"https://api.github.com/repos/rubygems/rubygems/issues/1143/labels{/name}","comments_url":"https://api.github.com/repos/rubygems/rubygems/issues/1143/comments","events_url":"https://api.github.com/repos/rubygems/rubygems/issues/1143/events","html_url":"https://github.com/rubygems/rubygems/pull/1143","id":54816174,"number":1143,"title":"Fix `generate_index` ignoring default gems","user":{"login":"juniorz","id":30809,"avatar_url":"https://avatars.githubusercontent.com/u/30809?v=3","gravatar_id":"","url":"https://api.github.com/users/juniorz","html_url":"https://github.com/juniorz","followers_url":"https://api.github.com/users/juniorz/followers","following_url":"https://api.github.com/users/juniorz/following{/other_user}","gists_url":"https://api.github.com/users/juniorz/gists{/gist_id}","starred_url":"https://api.github.com/users/juniorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juniorz/subscriptions","organizations_url":"https://api.github.com/users/juniorz/orgs","repos_url":"https://api.github.com/users/juniorz/repos","events_url":"https://api.github.com/users/juniorz/events{/privacy}","received_events_url":"https://api.github.com/users/juniorz/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rubygems/rubygems/labels/status%20-%20feedback","name":"status - feedback","color":"02d7e1"},{"url":"https://api.github.com/repos/rubygems/rubygems/labels/type%20-%20feature","name":"type - feature","color":"02e10c"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/rubygems/rubygems/milestones/12","html_url":"https://github.com/rubygems/rubygems/milestones/2.5","labels_url":"https://api.github.com/repos/rubygems/rubygems/milestones/12/labels","id":720820,"number":12,"title":"2.5","description":"","creator":{"login":"drbrain","id":9831,"avatar_url":"https://avatars.githubusercontent.com/u/9831?v=3","gravatar_id":"","url":"https://api.github.com/users/drbrain","html_url":"https://github.com/drbrain","followers_url":"https://api.github.com/users/drbrain/followers","following_url":"https://api.github.com/users/drbrain/following{/other_user}","gists_url":"https://api.github.com/users/drbrain/gists{/gist_id}","starred_url":"https://api.github.com/users/drbrain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/drbrain/subscriptions","organizations_url":"https://api.github.com/users/drbrain/orgs","repos_url":"https://api.github.com/users/drbrain/repos","events_url":"https://api.github.com/users/drbrain/events{/privacy}","received_events_url":"https://api.github.com/users/drbrain/received_events","type":"User","site_admin":false},"open_issues":32,"closed_issues":65,"state":"open","created_at":"2014-07-14T20:05:36Z","updated_at":"2015-04-27T20:52:46Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2015-01-19T21:44:34Z","updated_at":"2015-04-28T19:50:40Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/rubygems/rubygems/pulls/1143","html_url":"https://github.com/rubygems/rubygems/pull/1143","diff_url":"https://github.com/rubygems/rubygems/pull/1143.diff","patch_url":"https://github.com/rubygems/rubygems/pull/1143.patch"},"body":"`gem generate_index` should not ignore default gems if they are present in the directory containing the gems you want to index (the path pointed by the param --directory).\r\n\r\n```\r\n$ ruby -v && gem -v\r\nruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]\r\n2.4.5\r\n\r\n$ tree .\r\n.\r\n└── gems\r\n    ├── json-1.8.0.gem\r\n    ├── json-1.8.1.gem\r\n    └── sdoc-0.4.1.gem\r\n\r\n1 directory, 3 files\r\n$ gem generate_index -V\r\nGenerating Marshal quick index gemspecs for 2 gems\r\n1/2: json-1.8.0\r\n2/2: sdoc-0.4.1\r\nComplete\r\nGenerated Marshal quick index gemspecs: 0.001s\r\nGenerating specs index\r\nGenerated specs index: 0.000s\r\nGenerating latest specs index\r\nGenerated latest specs index: 0.000s\r\nGenerating prerelease specs index\r\nGenerated prerelease specs index: 0.000s\r\nCompressing indicies\r\nCompressed indicies: 0.001s\r\nMoving index into production dir .\r\nmkdir -p ./quick\r\nrm -rf ./quick/Marshal.4.8\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/quick/Marshal.4.8 ./quick/Marshal.4.8\r\nrm -rf ./specs.4.8\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/specs.4.8 .\r\nrm -rf ./specs.4.8.gz\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/specs.4.8.gz .\r\nrm -rf ./latest_specs.4.8\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/latest_specs.4.8 .\r\nrm -rf ./latest_specs.4.8.gz\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/latest_specs.4.8.gz .\r\nrm -rf ./prerelease_specs.4.8\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/prerelease_specs.4.8 .\r\nrm -rf ./prerelease_specs.4.8.gz\r\nmv -f /var/folders/gp/2qhc4gmx08s3twkvzm9jbmdh0000gn/T/gem_generate_index_88548/prerelease_specs.4.8.gz .\r\n```\r\n\r\n**The problem:** `json-1.8.1.gem` is included in the `gems` directory but is simply ignored.\r\n**The reason:** lib/rubygems/indexer.rb simply ignores every `default_gem?` regardless of its presence in the `gems` directory.\r\n\r\nSee https://github.com/rubygems/rubygems/issues/661#issuecomment-70561849 for more details."},"comment":{"url":"https://api.github.com/repos/rubygems/rubygems/issues/comments/97185065","html_url":"https://github.com/rubygems/rubygems/pull/1143#issuecomment-97185065","issue_url":"https://api.github.com/repos/rubygems/rubygems/issues/1143","id":97185065,"user":{"login":"juniorz","id":30809,"avatar_url":"https://avatars.githubusercontent.com/u/30809?v=3","gravatar_id":"","url":"https://api.github.com/users/juniorz","html_url":"https://github.com/juniorz","followers_url":"https://api.github.com/users/juniorz/followers","following_url":"https://api.github.com/users/juniorz/following{/other_user}","gists_url":"https://api.github.com/users/juniorz/gists{/gist_id}","starred_url":"https://api.github.com/users/juniorz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/juniorz/subscriptions","organizations_url":"https://api.github.com/users/juniorz/orgs","repos_url":"https://api.github.com/users/juniorz/repos","events_url":"https://api.github.com/users/juniorz/events{/privacy}","received_events_url":"https://api.github.com/users/juniorz/received_events","type":"User","site_admin":false},"created_at":"2015-04-28T19:50:40Z","updated_at":"2015-04-28T19:50:40Z","body":"From latest version, it skips the default gems (json-1.8.1, minitest-4.7.5 and rake-10.1.0)\r\n\r\n```\r\n$ ruby -v && gem -v\r\nruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]\r\n2.4.6\r\n$ tree .\r\n.\r\n├── gems\r\n│   ├── json-1.8.1.gem\r\n│   ├── json-1.8.2.gem\r\n│   ├── minitest-4.7.5.gem\r\n│   ├── rake-10.1.0.gem\r\n│   └── sdoc-0.4.1.gem\r\n├── latest_specs.4.8\r\n├── latest_specs.4.8.gz\r\n├── prerelease_specs.4.8\r\n├── prerelease_specs.4.8.gz\r\n├── quick\r\n│   └── Marshal.4.8\r\n│       ├── json-1.8.2.gemspec.rz\r\n│       └── sdoc-0.4.1.gemspec.rz\r\n├── specs.4.8\r\n└── specs.4.8.gz\r\n\r\n3 directories, 13 files\r\n$ ruby -e 'p Gem::Specification.to_a.select(&:default_gem?).collect(&:full_name)'\r\n[\"bigdecimal-1.2.4\", \"io-console-0.4.2\", \"json-1.8.1\", \"minitest-4.7.5\", \"psych-2.0.5\", \"rake-10.1.0\", \"rdoc-4.1.0\", \"test-unit-2.1.2.0\"]\r\n$ gem generate_index -V                                                                                           [⚡ ∞][15:39:21]\r\nGenerating Marshal quick index gemspecs for 2 gems\r\n1/2: json-1.8.2\r\n2/2: sdoc-0.4.1\r\nComplete\r\n[...]\r\n```\r\n\r\nRunning from master, it doesn't.\r\n\r\n```\r\n$ ruby -I/Users/king/src/github/rubygems/lib -e 'p Gem::Specification.to_a.select(&:default_gem?).collect(&:full_name)'\r\n[\"bigdecimal-1.2.4\", \"io-console-0.4.2\", \"json-1.8.1\", \"minitest-4.7.5\", \"psych-2.0.5\", \"rake-10.1.0\", \"rdoc-4.1.0\", \"test-unit-2.1.2.0\"]\r\n$ ruby -I/Users/king/src/github/rubygems/lib /Users/king/src/github/rubygems/bin/gem generate_index -v\r\nGenerating Marshal quick index gemspecs for 5 gems\r\n1/5: json-1.8.1\r\n2/5: json-1.8.2\r\n3/5: minitest-4.7.5\r\n4/5: rake-10.1.0\r\n5/5: sdoc-0.4.1\r\nComplete\r\n[...]\r\n```\r\n\r\nFrom my perspective, it was decided to use `Gem::Specification.each` to iterate over all the gem specs. To do so, it had to be mutated in order to include the gems located in the destination directory. Then #661 was reported because `Gem::Specification.each` includes all the default gems, and it was fixed by skipping the default gems :-1:\r\n\r\nThen this issue was reported because the default gems are skipped even if they are not coming from the default specifications directory (`Gem::BasicSpecification.default_specifications_dir`).\r\n\r\naad1014e124d65ed28dcd6580cbf6cf8441c1690 removes mutation on `Gem::Specification` and by consequence fixes this issue.\r\n\r\nThat makes me wonder if the `next if spec.default_gem?` is really necessary since it seems to be originally added to fix a consequence of mutating `Gem:Specification` (see #661).\r\n\r\nNow, `default_gem?` would only return true if `gem generate_index` is run on `Gem::BasicSpecification.default_specifications_dir` (the directory containing only the default gems) - and in this case it would skip all the gems.\r\n\r\nThat's why my PR becomes only removing the skip behavior."}}