Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Switch autoload to require source in plugin/api #5379

Closed
wants to merge 2 commits into from

Conversation

btsai
Copy link

@btsai btsai commented Jan 29, 2017

Should not use autoload :Source, "bundler/plugin/api/source" in plugin/api as this breaks sdoc, fastlane with this error:

# gems/bundler-1.14.3/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)

Thank you for merging in and putting out new gem!

This was originally a workaround fix in rubygems#5010, to prevent the following error in fastlane and rdoc on bundler 1.14.3, but the following commit undid this, and this errors is reappearing:
rubygems@6167ec8

```
gems/bundler-1.14.3/lib/bundler/rubygems_ext.rb:45:in `full_gem_path': uninitialized constant Bundler::Plugin::API::Source (NameError)
from /lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
```

This commit will revert that change.
@segiddins
Copy link
Member

This is a performance regression. Please add a test for the issue this is fixing and we'll try and come up with another fix.

@btsai
Copy link
Author

btsai commented Jan 29, 2017

Hi Sam,

This is happening at the basic gem loading, and as in spite of how long I've been doing RoR, I have never had to write a test at that low level, particularly when this appears to be a very interdependent case with fastlane or sdoc (I'm doing the latter).

It appears that upon loading the bundler gem, specifically when running from sdoc, we're hitting the line in
bundler-1.14.3/lib/bundler/rubygems_ext.rb:45

if source.respond_to?(:path) || source.is_a?(Bundler::Plugin::API::Source)

I did a stack trace to see who/how it was being called, and found that interestingly, that line is being called twice, and the first time it is being called, the Source class is defined, but not in the second one.

I hope this helps in identifying the source of the problem:

#***************************************************
# immediately after calling autoload inside api.rb when api.rb is loaded, Source is defined.
#***************************************************
lib/bundler/plugin/api.rb:27 defined?(Bundler::Plugin::API::Source): constant

#***************************************************
# the first time around in rubygems_ext.rb#full_require_paths, loading api.rb, Source is defined
#***************************************************
lib/bundler/rubygems_ext.rb:45 defined?(Bundler::Plugin::API::Source): constant
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `map'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1370:in `add_self_to_load_path'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1283:in `activate'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `synchronize'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `gem'
.rvm/gems/ruby-2.0.0-p648/bin/sdoc:22:in `<main>'
.rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:15:in `eval'
.rvm/gems/ruby-2.0.0-p648/bin/ruby_executable_hooks:15:in `<main>'

#***************************************************
# second time around in rubygems_ext.rb#full_require_paths when next loading the api/source.rb file, Source is not defined, which is puzzling because i've confirmed Source is in the Api namespace, above.
#***************************************************
lib/bundler/rubygems_ext.rb:45 defined?(Bundler::Plugin::API::Source): nil
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `map'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:76:in `contains_requirable_file?'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:64:in `block in require'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:63:in `each'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:63:in `find'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:63:in `require'
.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.14.3/lib/bundler/plugin/api/source.rb:2:in `<top (required)>'
.rvm/gems/ruby-2.0.0-p648/gems/bundler-1.14.3/lib/bundler/rubygems_ext.rb:47:in `full_gem_path'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:144:in `block in full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `map'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/basic_specification.rb:143:in `full_require_paths'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1370:in `add_self_to_load_path'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:1283:in `activate'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:67:in `block in gem'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `synchronize'
.rvm/rubies/ruby-2.0.0-p648/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_gem.rb:66:in `gem'
.rvm/gems/ruby-2.0.0-p648/bin/sdoc:22:in `<main>'

@segiddins
Copy link
Member

How do I reproduce this issue?

@btsai
Copy link
Author

btsai commented Jan 30, 2017

install the sdoc gem (gem install sdoc), and point it at a folder with ruby files in it:
sdoc PATH_TO_SOURCE_FOLDER -op PATH_TO_OUTPUT_FOLDER.

@colby-swandale
Copy link
Member

colby-swandale commented Jan 30, 2017

I'm unable to replicate this error. Can you provide more details of your environment with bundle env

› ruby -v
ruby 2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin16.5.0]
› bundler -v
Bundler version 1.14.3
› sdoc bundler -op example
Parsing sources...
100% [61/61]  bundler/lib/bundler

Generating SDoc format into /Users/colby/Desktop/Projects/example...

Files:       61

Classes:     42 ( 1 undocumented)
Modules:     24 ( 7 undocumented)
Constants:   53 (11 undocumented)
Attributes:  63 (10 undocumented)
Methods:    342 (61 undocumented)

Total:      524 (90 undocumented)
 82.82% documented

Elapsed: 3.4s

@btsai
Copy link
Author

btsai commented Jan 30, 2017

Hi,

Does this help? Looks like we're on the same env, roughly...

Bundler   1.14.3
Rubygems  2.4.8
Ruby      2.0.0p648 (2015-12-16 revision 53162) [x86_64-darwin14.3.0]
GEM_HOME  /Users/btsai/.rvm/gems/ruby-2.0.0-p648
GEM_PATH  /Users/btsai/.rvm/gems/ruby-2.0.0-p648:/Users/btsai/.rvm/gems/ruby-2.0.0-p648@global
RVM       1.27.0 (latest)
Git       2.6.4
Platform  x86_64-darwin-14
rubygems-bundler (1.4.4)

@colby-swandale
Copy link
Member

Can you update your version of rubygems gem update --system and try again.

@btsai
Copy link
Author

btsai commented Jan 31, 2017

thank you for the suggestion - i'll have to find a machine that i can reset with a fresh install - i've found that updating rubygems often has a large trickle-on effect.

cheers

@segiddins
Copy link
Member

I can't reproduce this on either RubyGems 2.6.10 or 2.4.8

@colby-swandale
Copy link
Member

ping @btsai

@segiddins
Copy link
Member

This should no longer be required as of 1.14.6

@segiddins segiddins closed this Mar 15, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants