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

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.

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”

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

Frederick C. 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:inconst_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?

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.

On Oct 1, 8:56 pm, Shawn P. [email protected]
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/browse_thread/thread/710868b1292c737f/9e39c0716569a355?lnk=gst&q=module+tree#9e39c0716569a355).
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

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/browse_thread/thread/9067bce01444fb24#

“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 :slight_smile:

-r

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).