-
-
Notifications
You must be signed in to change notification settings - Fork 925
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Autoload is not overwritten by subsequent explicit require #3656
Comments
Patch for rubygems.rb that makes this work correctly. It should not be necessary: diff --git a/lib/ruby/stdlib/rubygems.rb b/lib/ruby/stdlib/rubygems.rb
index f0861b3..fd0b513 100644
--- a/lib/ruby/stdlib/rubygems.rb
+++ b/lib/ruby/stdlib/rubygems.rb
@@ -1222,7 +1222,7 @@ module Gem
autoload :Source, 'rubygems/source'
autoload :SourceList, 'rubygems/source_list'
autoload :SpecFetcher, 'rubygems/spec_fetcher'
- autoload :Specification, 'rubygems/specification'
+ # autoload :Specification, 'rubygems/specification'
autoload :Version, 'rubygems/version'
require "rubygems/specification" |
After a bit more research, this is a missing behavior of autoloads for us. When autoloading, the path to be loaded is given to Because we do not do this search (and we do not have the structures in place to support it) we end up triggering the autoload again even if it should have been wiped out by a normal require. |
Only reported as a failure in a new 2.3 test, so bumping for now to post 9.1. |
Just ran into this while trying to generate a config file with warbler on a server which is a bit puzzling because I wasn't able to reproduce it while using rbenv on my local machine on a new Rails app. |
I believe this is the cause of failures I'm seeing with rubber now (by way of fog): https://travis-ci.org/rubber/rubber/jobs/188061119 Fog interfaces to many different providers. It also has a built-in mocking system so requests don't hit actual cloud providers. Part of the mocking system is a reset action to clear in-memory state. Rather than keep a global list of all loaded providers, it cycles through its known list of providers and sees which ones are set to autoload. Those that aren't are assumed to be loaded and those that are to be autoloaded are skipped since they shouldn't be in use: Since JRuby isn't clearing the autoload state, the mock cleanup is skipped and bad data lingers around causing test failures for Rubber. This seems to be a regression from JRuby 1.7. I dropped it out of the Rubber test suite because dependencies started going Ruby 2.0+ only, but tests used to pass fine previously. |
This will be fixed once #5764 lands. |
I'm trying to fix
TestAutoload#test_require_implemented_in_ruby_is_called
from the MRI suite. The patch I started with is below.This matches MRI's behavior and appears to fix the test, except for a little snag...another test starts to fail with a StackOverflowError:
This is happening inside
kernel_require.rb
at the point where it first accessesGem::Specification
, and unsurprisingly an autoload in RubyGems' require will redispatch to require and trigger this overflow. However, even thoughGem::Specification
is set up as an autoload forrubygems/specification
, that file is immediately required inrubygems.rb
and should overwrite the autoload version.I do not know why this is happening. If I comment out the autoload, my patch works fine.
The text was updated successfully, but these errors were encountered: