Finally accepting the fact that autoload will never be fixed (i.e. there
it
no way to override require to effect autoload’s behavior) I decided to
try re-implementing autoload in Ruby itself.
So here’s what I arrived at:
https://github.com/rubyworks/autoload/blob/master/lib/autoload.rb
I thought that was it, but then I tried a bundle exec call with this
autoload.rb loaded (via RUBYOPT), and it bombs.
autoload.rb:104:in `const_missing': uninitialized constant
Module::Settings (NameError)
from
/home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler.rb:191:in
settings' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler.rb:330:inconfigure_gem_home_and_path’
from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler.rb:86:in
configure' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler.rb:142:indefinition’
from
/home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/cli.rb:423:in
exec' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/vendor/thor/task.rb:27:inrun’
from
/home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/vendor/thor/invocation.rb:120:in
invoke_task' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/vendor/thor.rb:275:indispatch’
from
/home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/vendor/thor/base.rb:408:in
start' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/bin/bundle:14:inblock
in <top (required)>’
from
/home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/lib/bundler/friendly_errors.rb:4:in
with_friendly_errors' from /home/trans/.gem/ruby/1.9.3/gems/bundler-1.2.3/bin/bundle:14:in<top
(required)>’
from /home/trans/.gem/ruby/1.9.3/bin/bundle:23:in `’
Turns out that the self in const_missing that causes this is
#<Class:Bundler>. How can I workout the Bundler namespace given
that?
All other advice on improving this is also appreciated.