# Autoload ain't down with the program

**URL:** <https://rubytalk.org/t/autoload-aint-down-with-the-program/41736>\
**Category:** ruby-talk\
**Created:** [29 October 2007 03:25 UTC](https://rubytalk.org/t/autoload-aint-down-with-the-program/41736 "2007-10-29T03:25:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [29 October 2007 03:25 UTC](https://rubytalk.org/t/autoload-aint-down-with-the-program/41736/1 "2007-10-29T03:25:42Z")

</div>

I run into a bit of a snag. I've augmented the #require and #load  
methods and noticed that #autoload doesn't pick up on it --though the  
docs say #autoload uses #require. Apparently it uses it's own internal  
code though, separate from any defined in the script. So there seems  
to be no way to override #autoload to tie in these augmentations.

This also has an effect on Rubygems, btw. Notice:

&nbsp;&nbsp;&nbsp;require 'rubygems'  
&nbsp;&nbsp;&nbsp;autoload(:RedCloth, 'redcloth')  
&nbsp;&nbsp;&nbsp;p RedCloth

produces

&nbsp;&nbsp;&nbsp;no such file to load -- redcloth (LoadError)

even though the redcloth gem is in fact installed.

I suspect there's no way around this. If so, can we get that fixed in  
the next release of Ruby?

Thanks,  
-T.

(I know, this should probably go to ruby-core list. But I  
(purposefully) do not subscribe to that list any more.)

---

<div class="post-metadata">

**Author:** ![a11](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/a11/32/8169_2.png) [@a11](https://rubytalk.org/u/a11)\
**Post date:** [29 October 2007 15:25 UTC](https://rubytalk.org/t/autoload-aint-down-with-the-program/41736/2 "2007-10-29T15:25:01Z")

</div>

it works for me:

cfp:~ \> ruby -e' autoload "Dike", "dike.rb"; p Dike '  
Dike

cfp:~ \> ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p Dike '  
Dike

are you sure that autoload line works in isolation?

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

> **···**
>
> On Oct 28, 2007, at 9:25 PM, Trans wrote:
> 
> > I run into a bit of a snag. I've augmented the #require and #load  
> > methods and noticed that #autoload doesn't pick up on it --though the  
> > docs say #autoload uses #require. Apparently it uses it's own internal  
> > code though, separate from any defined in the script. So there seems  
> > to be no way to override #autoload to tie in these augmentations.
> > 
> > This also has an effect on Rubygems, btw. Notice:
> > 
> > &nbsp;&nbsp;&nbsp;require 'rubygems'  
> > &nbsp;&nbsp;&nbsp;autoload(:RedCloth, 'redcloth')  
> > &nbsp;&nbsp;&nbsp;p RedCloth
> > 
> > produces
> > 
> > &nbsp;&nbsp;&nbsp;no such file to load -- redcloth (LoadError)
> > 
> > even though the redcloth gem is in fact installed.
> > 
> > I suspect there's no way around this. If so, can we get that fixed in  
> > the next release of Ruby?
> > 
> > Thanks,  
> > -T.
> > 
> > (I know, this should probably go to ruby-core list. But I  
> > (purposefully) do not subscribe to that list any more.)
> 
> --  
> it is not enough to be compassionate. you must act.  
> h.h. the 14th dalai lama

---

<div class="post-metadata">

**Author:** ![a11](https://yyz1.discourse-cdn.com/flex029/user_avatar/rubytalk.org/a11/32/8169_2.png) [@a11](https://rubytalk.org/u/a11)\
**Post date:** [29 October 2007 16:34 UTC](https://rubytalk.org/t/autoload-aint-down-with-the-program/41736/3 "2007-10-29T16:34:04Z")

</div>

it works for me:

cfp:~ \> ruby -e' autoload "Dike", "dike.rb"; p Dike '  
Dike

cfp:~ \> ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p Dike '  
Dike

are you sure that autoload line works in isolation?

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

> **···**
>
> On Oct 28, 2007, at 9:25 PM, Trans wrote:
> 
> > I run into a bit of a snag. I've augmented the #require and #load  
> > methods and noticed that #autoload doesn't pick up on it --though the  
> > docs say #autoload uses #require. Apparently it uses it's own internal  
> > code though, separate from any defined in the script. So there seems  
> > to be no way to override #autoload to tie in these augmentations.
> > 
> > This also has an effect on Rubygems, btw. Notice:
> > 
> > &nbsp;&nbsp;&nbsp;require 'rubygems'  
> > &nbsp;&nbsp;&nbsp;autoload(:RedCloth, 'redcloth')  
> > &nbsp;&nbsp;&nbsp;p RedCloth
> > 
> > produces
> > 
> > &nbsp;&nbsp;&nbsp;no such file to load -- redcloth (LoadError)
> > 
> > even though the redcloth gem is in fact installed.
> > 
> > I suspect there's no way around this. If so, can we get that fixed in  
> > the next release of Ruby?
> > 
> > Thanks,  
> > -T.
> > 
> > (I know, this should probably go to ruby-core list. But I  
> > (purposefully) do not subscribe to that list any more.)
> 
> --  
> it is not enough to be compassionate. you must act.  
> h.h. the 14th dalai lama

---

<div class="post-metadata">

**Author:** ![7rans](https://avatars.discourse-cdn.com/v4/letter/7/a8b319/32.png) [@7rans](https://rubytalk.org/u/7rans)\
**Post date:** [29 October 2007 17:08 UTC](https://rubytalk.org/t/autoload-aint-down-with-the-program/41736/4 "2007-10-29T17:08:40Z")

</div>

Isolation from? Where do you have dike.rb installed? Is it a gem?

&nbsp;&nbsp;$ ruby -e'require "rubygems"; require "redcloth.rb"; p RedCloth'  
&nbsp;&nbsp;RedCloth  
&nbsp;&nbsp;$ ruby -e'require "rubygems"; autoload "RedCloth", "redcloth.rb"; p  
RedCloth'  
&nbsp;&nbsp;-e:1: no such file to load -- redcloth.rb (LoadError)

&nbsp;&nbsp;$ ruby --version  
&nbsp;&nbsp;ruby 1.8.6 (2007-06-07 patchlevel 36) [i486-linux]

&nbsp;&nbsp;$ gem --version  
&nbsp;&nbsp;0.9.4

T.

> **···**
>
> On Oct 29, 11:25 am, "ara.t.howard" \<ara.t.how...@gmail.com\> wrote:
> 
> > On Oct 28, 2007, at 9:25 PM, Trans wrote:
> > 
> > \> I run into a bit of a snag. I've augmented the #require and #load  
> > \> methods and noticed that #autoload doesn't pick up on it --though the  
> > \> docs say #autoload uses #require. Apparently it uses it's own internal  
> > \> code though, separate from any defined in the script. So there seems  
> > \> to be no way to override #autoload to tie in these augmentations.
> > 
> > \> This also has an effect on Rubygems, btw. Notice:
> > 
> > \> require 'rubygems'  
> > \> autoload(:RedCloth, 'redcloth')  
> > \> p RedCloth
> > 
> > \> produces
> > 
> > \> no such file to load -- redcloth (LoadError)
> > 
> > \> even though the redcloth gem is in fact installed.
> > 
> > \> I suspect there's no way around this. If so, can we get that fixed in  
> > \> the next release of Ruby?
> > 
> > \> Thanks,  
> > \> -T.
> > 
> > \> (I know, this should probably go to ruby-core list. But I  
> > \> (purposefully) do not subscribe to that list any more.)
> > 
> > it works for me:
> > 
> > cfp:~ \> ruby -e' autoload "Dike", "dike.rb"; p Dike '  
> > Dike
> > 
> > cfp:~ \> ruby -e' require "rubygems"; autoload "Dike", "dike.rb"; p  
> > Dike '  
> > Dike
> > 
> > are you sure that autoload line works in isolation?
