Forum: Ruby on Rails A copy of XX has been removed from the module tree but is still active!

E11e5f06674e87355a8d4363e3ab5406?d=identicon&s=25 histrionics (Guest)
on 2008-05-15 01:45
(Received via mailing list)
I have a class in my /lib/ directory called tracker.rb

It's function is to receive an array of URLs and then perform 4
separate tasks on each URL

Each of the 4 tasks gets it's own thread.

the class is called from my controller like:

output = Tracker.go([array_of_urls])

Sometimes, when it hits an exception, instead of just dieing
gracefully, my logs repeatedly display:

A copy of Tracker has been removed from the module tree but is still
active!

After this happens, I have to reboot my development server before it
will respond again.


Any ideas how or why this is happening?

Many thanks in advance for your insight.
E11e5f06674e87355a8d4363e3ab5406?d=identicon&s=25 histrionics (Guest)
on 2008-05-15 01:57
(Received via mailing list)
Some more information:

Usually, when I get this "A copy of Tracker has been removed from the
module tree but is still active!" error, the exception raised is:

wrong status line: "A\353\307\351\245}\243Z\213\364\232\3117\203w?
\axcnv\313\356\230v\350\345\f\346\032e\262\2148\002$hZ\3163\362'\373N+e
\3306\005'\3555\241\016\340\364\351\022+\333\340F\b
\372\274\244\357\004\212\241\026\325)6v\0056\t\374\017\023N%
\352\214\207\267R_,\017e^\3321\327Gq\031!
gG5\020\241\3565\356\200\3053\233\e\237\201\313\367\351/\327\206u.S
\331z.\023\326'\2277\303\v\361\366a\270\304yf\376\315h
\257\345A{\226\264\2352?\365\335\001_Hl:F\2429\322\250\320k\250\002k
\315\332\200\226\027P\374\335\363&\344\201#t<\355\360.\331\365?(X=:5Y
\240w6\365x\310\367\346\3368\315\350>W\370\034\377\351Uk\001iOW.=\300k
\036\351\307\323\303N\315\243\240\326eu\375AP,
\326\243\036\263\306\250\313\335\254hm/H\254L\251\212=
\334\022\363\366\251W\251UK\227W\373\215E\346\223\3316\343\375 \a
\336\347\224\355\224u\017\tq\006\364\v\334\346O\355\205s
\317\031\202\260\322'v?\2303\022\210\0062\002\300j\212mo^\254R\334=?
\275\331cu'\320G\216\021\353Sb\223\234\037\262\200s\367\a"
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-05-15 11:24
(Received via mailing list)
On 15 May 2008, at 00:44, histrionics wrote:

> output = Tracker.go([array_of_urls])
>
> Sometimes, when it hits an exception, instead of just dieing
> gracefully, my logs repeatedly display:
>
I bet if you switched to production mode it would work. What I think
is happening is:

- request calls Tracker.go
- Rails unloads loaded classes (since we're in dev mode)
- You threads continue to run trying to use classes that rails has
unloaded. Chaos ensues.

Fred
31978325b9596b56d9f79303cee97dc2?d=identicon&s=25 Shawn Pyle (spyle)
on 2008-10-01 21:56
Frederick Cheung wrote:
> I bet if you switched to production mode it would work. What I think
> is happening is:
>
> - request calls Tracker.go
> - Rails unloads loaded classes (since we're in dev mode)
> - You threads continue to run trying to use classes that rails has
> unloaded. Chaos ensues.
>
> Fred

Bingo! Putting my application in production mode allowed me to make
continual requests. It, however, doesn't solve the problem though.

Problem:
I've got a module (AccessControl) in RAILS_ROOT/lib that extends my
controllers (which inherit from ResourceController) and adds
functionality to AuthenticatedSystem.  In development mode, this works
fine via requests through the browser. However, once I try to consume
the resources with ActiveResource, the first request succeeds and the
next request fails with the following error:

ArgumentError (A copy of AccessControl has been removed from the module
tree but is still active!):
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:250:in
`load_missing_constant'
    /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.1.1/lib/active_support/dependencies.rb:468:in
`const_missing'
    /lib/access_control.rb:122:in `controller_target'
...

I can't figure out why this would work via the browser but not through
ActiveResource. The only thing that's different, if I understand it
correctly, are the headers:
    Accept: application/xml
    Content-Type: application/xml

Why would that make a difference? Not only that, the error is
originating in the class it says it can't find. Does anyone understand
why this might be the case?
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-10-01 23:27
(Received via mailing list)
On Oct 1, 8:56 pm, Shawn Pyle <rails-mailing-l...@andreas-s.net>
wrote:
>
> Bingo! Putting my application in production mode allowed me to make
> continual requests. It, however, doesn't solve the problem though.
>

The depedencies system has been confused: something is referencing an
old copy of the module but that old copy should not be used anymore
(since rails has reloaded a fresh copy). This can be caused by using
require inappropriately (http://spacevatican.org/2008/9/28/required-or-
not) or when things that shouldn't be reloaded are reloaded (this can
be changed by adding files to Dependencies.load_once_paths (see also
http://groups.google.com/group/rubyonrails-core/br...).
In your case I'd guess the latter - you're extending something like a
plugin (which isn't reloaded between requests) with something that is
reloaded between requests = trouble.

Fred
Ecff2e8d01672a7b3d26a3c4c962fc5b?d=identicon&s=25 Mikhail Shalai (stwoland)
on 2009-07-14 10:20
>ArgumentError (A copy of AccessControl has been removed from the module tree but is still 
active!):

Check your environments/development.rb for config.cache_classes and try
setting it to true:
config.cache_classes = true #false

It worked for me. It should also help, if you're using RubyInline and
have created some C/C++ methods in a class. In my case, I simply make a
system call to run an external binary.

You may also want to try and put your code in a gem, as it gets loaded
every time you start the server, and doesn't get unloaded.
Ecff2e8d01672a7b3d26a3c4c962fc5b?d=identicon&s=25 Mikhail Shalai (stwoland)
on 2009-07-14 10:24
Sorry, forgot to mention. You need to restart the server after modifying
the config file (and will have to restart it every time you make any
changes to your classes, too).
Bec38d63650c8912b6ba9b557fb953b9?d=identicon&s=25 Roger Pack (rogerdpack)
on 2009-08-10 14:24
> A copy of Tracker has been removed from the module tree but is still
> active!
>
> After this happens, I have to reboot my development server before it
> will respond again.
>
> Any ideas how or why this is happening?

Appears that it can occur when a plugin [which isn't reloaded] keeps a
reference to a normal class [which is reloaded].

ex: engines don't reload, normal app does, if there was any
intermingling boom!
http://groups.google.com/group/rubyonrails-core/br...

"a copy of OrderHelper has been removed from the module tree"

I think that's what happens to me, anyway.
So much for the usefulness of dev. mode :)

-r
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.