circular dependency - Expected .../app/models/user.rb to define User (LoadError)
Added by Luca Pireddu about 15 years ago
Hello. Is there any generic solution for this problem? I'm trying to get the redmine_local_avatars plugin to run in development mode. It patches the User class to add some functionality, and unfortunately it doesn't work in development mode for the often seen problem of the plugin files not being reloaded.
To resolve the issue I tried to apply the solution described by Eric Davis using Dispatcher.to_prepare
. I defined a block as like this:
Dispatcher.to_prepare(:local_avatars_user) do User.send(:include, LocalAvatarsPlugin::UsersAvatarPatch) end
Unfortunately this results in a LoadError:
ERROR LoadError: Expected /home/<snip>/.../redmine/app/models/user.rb to define User
The problem seems to be that the system doesn't handle a circular dependency. This can be seen from the stack trace
app/models/user.rb to define User app/models/project.rb:23 app/models/principal.rb:22 app/models/user.rb:20 vendor/plugins/redmine_local_avatars/lib/users_avatar_patch.rb:19
users_avatar_patch.rb:19 is the line User.send(:include, LocalAvatarsPlugin::UsersAvatarPatch)
Any suggestions on how to resolve this issue? In production mode it seems to work fine.
Replies (4)
RE: circular dependency - Expected .../app/models/user.rb to define User (LoadError) - Added by Alexey Palazhchenko about 15 years ago
Add
require_dependency 'principal'before
require_dependency 'user'
RE: circular dependency - Expected .../app/models/user.rb to define User (LoadError) - Added by Brian Wells about 15 years ago
I also ran into this problem. It went away only after I also patched the Principal model to be unloadable.
– Brian Wells
RE: circular dependency - Expected .../app/models/user.rb to define User (LoadError) - Added by Dmitry Salashnik about 15 years ago
Aleksey Palazhchenko wrote:
Add [...] before [...]
YES!!! :)
RE: circular dependency - Expected .../app/models/user.rb to define User (LoadError) - Added by Jaroslav K. almost 15 years ago
Hello,
I have the same issue when try install redmine_ezsummary plugin. What can I do?
For more info and error logs see last post: http://www.redmine.org/boards/3/topics/6612#message-11555
Thank you for info.