Bug #2056
uninitialized constant RepositoryObserver
100%
Description
I followed the wiki to install.
when running rake redmine:plugins:migrate RAILS_ENV=production
it errors out with this error
rake aborted!
uninitialized constant RepositoryObserver
Trace attached
History
#1 Updated by Andriy Lesyuk over 12 years ago
- Status changed from New to Incomplete
#2 Updated by Andriy Lesyuk over 12 years ago
If version is 0.4.0, as I understood, this error happens only when executing rake redmine:plugins:migrate RAILS_ENV=production
...
As a workaround you can comment line 14 of source:init.rb, migrate, then uncomment and restart Redmine.
Please confirm the version and if the workaround works.
#3 Updated by Rob Landry over 12 years ago
i am pretty sure the version is trunk as i checked it out. i am not sure where to find the version. Also the work around has failed. i get a passenger error page once restarting apache2 and loading the page.
Ruby on Rails application could not be startedThese are the possible causes:
There may be a syntax error in the application’s code. Please check for such errors and fix them.
A required library may not installed. Please install all libraries that this application requires.
The application may not be properly configured. Please check whether all configuration files are written correctly, fix any incorrect configurations, and restart this application.
A service that the application relies on (such as the database server or the Ferret search engine server) may not have been started. Please start that service.
Further information about the error may have been written to the application’s log file. Please check it in order to analyse the problem.
Error message:
uninitialized constant RepositoryObserver
Exception class:
NameError
Application root:
/home/rob/www/redmine
Backtrace:
- File Line Location
0 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb 229 in `block in constantize’
1 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb 228 in `each’
2 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/inflector/methods.rb 228 in `constantize’
3 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/core_ext/string/inflections.rb 54 in `constantize’
4 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.6/lib/active_model/observing.rb 86 in `instantiate_observer’
5 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.6/lib/active_model/observing.rb 59 in `block in instantiate_observers’
6 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.6/lib/active_model/observing.rb 59 in `each’
7 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activemodel-3.2.6/lib/active_model/observing.rb 59 in `instantiate_observers’
8 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/railtie.rb 117 in `block (2 levels) in '
9 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 36 in `instance_eval’
10 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 36 in `execute_hook’
11 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 26 in `block in on_load’
12 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 25 in `each’
13 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 25 in `on_load’
14 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activerecord-3.2.6/lib/active_record/railtie.rb 116 in `block in '
15 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 34 in `call’
16 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 34 in `execute_hook’
17 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 43 in `block in run_load_hooks’
18 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 42 in `each’
19 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/activesupport-3.2.6/lib/active_support/lazy_load_hooks.rb 42 in `run_load_hooks’
20 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/application/finisher.rb 59 in `block in '
21 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb 30 in `instance_exec’
22 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb 30 in `run’
23 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb 55 in `block in run_initializers’
24 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb 54 in `each’
25 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/initializable.rb 54 in `run_initializers’
26 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/application.rb 136 in `initialize!'
27 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/railties-3.2.6/lib/rails/railtie/configurable.rb 30 in `method_missing’
28 /home/rob/www/redmine/config/environment.rb 14 in `'
29 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in `require’
30 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/classic_rails/application_spawner.rb 222 in `preload_application’
31 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/classic_rails/application_spawner.rb 181 in `block in initialize_server’
32 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/utils.rb 572 in `report_app_init_status’
33 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/classic_rails/application_spawner.rb 174 in `initialize_server’
34 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb 204 in `start_synchronously’
35 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb 180 in `start’
36 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/classic_rails/application_spawner.rb 149 in `start’
37 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb 219 in `block (2 levels) in spawn_rails_application’
38 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb 132 in `lookup_or_add’
39 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb 214 in `block in spawn_rails_application’
40 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb 82 in `block in synchronize’
41 prelude> 10:in `synchronize’
42 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server_collection.rb 79 in `synchronize’
43 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb 213 in `spawn_rails_application’
44 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb 132 in `spawn_application’
45 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/spawn_manager.rb 275 in `handle_spawn_application’
46 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb 357 in `server_main_loop’
47 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/lib/phusion_passenger/abstract_server.rb 206 in `start_synchronously’
48 /home/rob/.rvm/gems/ruby-1.9.3-p194/gems/passenger-3.0.13/helper-scripts/passenger-spawn-server 99 in `'
#4 Updated by Rob Landry over 12 years ago
my configuration:
production:
deny_delete: false
auto_create: false
force_repository: false
pre_create: /usr/local/bin/pre-create.sh
post_create: /usr/local/bin/post-create.sh
pre_delete: /usr/local/bin/pre-delete.sh
post_delete: /usr/local/bin/post-delete.sh
max_repos: 0
only_creator: false
allow_add_local: false
allow_pickup: false
svn:
path: /repo/svn
svnadmin: /usr/bin/svnadmin
url: svn
git:
path: /repo/git
git: /usr/bin/git
options: --bare
url: http://git.landry.me
update_server_info: true
git_ext: true
append: trunk
mercurial:
path: /var/lib/mercurial
hg: /usr/bin/hg
bazaar:
path: /var/lib/bazaar
bzr: /usr/bin/bzr
init: init-repository
log_encoding: UTF-8
development:
#5 Updated by Andriy Lesyuk over 12 years ago
The workaround should work only at the time of migration, that is, when you run rake redmine:plugins:migrate RAILS_ENV=production
...
Replace the line with: Rails.configuration.active_record.observers << :repository_observer
However, in my case, RepositoryObserver does not work with this change (no error - just does not get called).
#6 Updated by Rob Landry over 12 years ago
the db migration runs fine with this line “#” commented out. however after removing the comment, and restarting apache2 (redmine) with sudo service apache2 restart and then going to me base page redmine.landry.me i get the previously posted error.
#7 Updated by Andriy Lesyuk over 12 years ago
I got it. Thanks! Weird, that it works for me...
#8 Updated by Rob Landry over 12 years ago
well, what is different with my setup? that has to be the cause of the error if it works for you.
my full system specs are:
Ubuntu 12.04
Apache/2.2.22 (Ubuntu)
perl 5, version 14, subversion 2 (v5.14.2) built for i686-linux-gnu-thread-multi-64int
ruby 1.9.3p194 (2012-04-20 revision 35410) [i686-linux]
Phusion Passenger version 3.0.13
redmine 2.0.3
- LOCAL GEMS ***
actionmailer (3.2.6, 3.2.5)
actionpack (3.2.6, 3.2.5)
activemodel (3.2.6, 3.2.5)
activerecord (3.2.6, 3.2.5)
activeresource (3.2.6, 3.2.5)
activesupport (3.2.6, 3.2.5)
arel (3.0.2)
autotest-notification (2.3.4)
autotest-rails (4.1.2)
autotest-standalone (4.5.9)
bigdecimal (1.1.0)
builder (3.0.0)
bundler (1.1.4)
coderay (1.0.6)
daemon_controller (1.0.0)
diff-lcs (1.1.3)
erubis (2.7.0)
factory_girl (3.5.0)
factory_girl_rails (3.5.0)
fastercsv (1.5.5)
fastthread (1.0.7)
hike (1.2.1)
i18n (0.6.0)
journey (1.0.4)
json (1.7.3)
mail (2.4.4)
metaclass (0.0.1)
mime-types (1.19)
mocha (0.11.4)
multi_json (1.3.6)
mysql (2.8.1)
mysql2 (0.3.11)
net-ldap (0.3.1)
passenger (3.0.13)
pg (0.13.2)
polyglot (0.3.3)
prototype-rails (3.2.1)
rack (1.4.1)
rack-cache (1.2)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.2.6, 3.2.5)
railties (3.2.6, 3.2.5)
rake (0.9.2.2)
rdoc (3.12)
rmagick (2.13.1)
rspec (1.3.0)
rspec-core (2.10.1)
rspec-expectations (2.10.0)
rspec-mocks (2.10.1)
rspec-rails (1.3.0)
ruby-openid (2.1.8)
rubygems-bundler (1.0.3)
rvm (1.11.3.4)
shoulda (2.11.3)
shoulda-matchers (1.2.0)
simplecov (0.6.4)
simplecov-html (0.5.3)
simplecov-rcov (0.2.3)
sprockets (2.1.3)
sqlite3 (1.3.6)
test-unit (2.5.0)
thor (0.15.3)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.33)
yard (0.8.2.1)
ZenTest (4.8.1)
Anything else you think might be helpful?
#9 Updated by Andriy Lesyuk over 12 years ago
well, what is different with my setup? that has to be the cause of the error if it works for you.
Don’t think I’m going to leave this issue! Just thought aloud...
I’m using Redmine 2.0.0 but I don’t think that’s the reason! Because I actually used to get the same behaviour but after that for some reason is started to work... So I thought I have fixed it accidentally.
Anything else you think might be helpful?
Please try replacing the line with Rails.configuration.active_record.observers << :repository_observer
. Also it would be cool if you could try deleting a repository created with SCM Creator and with deny_delete
option set to false
.
#10 Updated by Andriy Lesyuk over 12 years ago
- Status changed from Incomplete to In Progress
- Assignee set to Andriy Lesyuk
- % Done changed from 0 to 50
Could you please first try the following:
Add ActiveRecord::Base.instantiate_observers
below ActiveRecord::Base.observers << :repository_observer
? E.g.
...
Rails.logger.info 'Starting SCM Creator Plugin for Redmine'
ActiveRecord::Base.observers << :repository_observer
ActiveRecord::Base.instantiate_observers
Rails.configuration.to_prepare do
...
See: http://railsforum.com/viewtopic.php?id=19305
Other options:- Move
ActiveRecord::Base.observers << :repository_observer
at the end ofinit.rb
file. - Put it inside
config.after_initialize do
like here: https://github.com/cjAdvertising/redmine_git_hosting/commit/7e9f46b338d9359a1956850f99a817b844667e0d#init.rb
#11 Updated by Rob Landry over 12 years ago
Adding ActiveRecord::Base.instantiate_observers
below ActiveRecord::Base.observers << :repository_observer
causes same error
Moving to end of file causes same error
Adding to:
# initialize observer config.after_initialize do ActiveRecord::Base.observers = ActiveRecord::Base.observers << GitHosti$ end
causes this error:
rake aborted!
undefined local variable or method `config’ for main:Object
#12 Updated by Andriy Lesyuk over 12 years ago
What about:
# initialize observer Rails.configuration.after_initialize do ActiveRecord::Base.observers = ActiveRecord::Base.observers << GitHosti$ end
?
And please try: Rails.configuration.active_record.observers << :repository_observer
+ deleting a repositiry (see above).
#13 Updated by Rob Landry over 12 years ago
With this
# initialize observer Rails.configuration.after_initialize do ActiveRecord::Base.observers = ActiveRecord::Base.observers << :repository_observer end
Allowed Rake to complete!
Now to see if everything works as expected.
#14 Updated by Rob Landry over 12 years ago
Not sure if related, but now i get an error when trying to add a new project. this occurs using the same config previously posted.
#15 Updated by Rob Landry over 12 years ago
rake db:migrate:plugin NAME=scm_creator VERSION=0 RAILS_ENV=production
(in /home/rob/www/redmine)
Plugin scm_creator was not found.
i am not sure that the db was actually updated. however i do see the plugin listed under plugins, just cannot add a new project.
#16 Updated by Andriy Lesyuk over 12 years ago
rake db:migrate:plugin NAME=scm_creator VERSION=0 RAILS_ENV=production
Just remove the plugin’s directory – no need to clean database...
Not sure if related, but now i get an error when trying to add a new project. this occurs using the same config previously posted.
There should be error in logs – what is it?
#17 Updated by Andriy Lesyuk over 12 years ago
Now to see if everything works as expected.
Ok, for me, RepositoryObserver does not get called...
#18 Updated by Andriy Lesyuk over 12 years ago
- Target version set to 0.4.1
#19 Updated by Andriy Lesyuk over 12 years ago
Just another link: http://riotprojects.com/post/106808946/activerecord-observers-in-gems-plugins
Have some new ideas... Not sure how to test though... Hope you will help me?
Anyone else experiencing the same issue?...
#20 Updated by Rob Landry over 12 years ago
Willing to help. Just let me know what you need.
#21 Updated by Andriy Lesyuk over 12 years ago
- % Done changed from 50 to 90
Please try the latest code from SVN. I believe the issue should be fixed now! Need your confirmation.
#22 Updated by Andriy Lesyuk over 12 years ago
P.S. Our discussion brought me to the idea: #2079...
#23 Updated by Rob Landry over 12 years ago
Great success! Works great. Looks like you found the issue and fixed it. Thank you.
#24 Updated by Andriy Lesyuk over 12 years ago
- Due date set to 29 Jun 2012
- % Done changed from 90 to 100
Great success! Works great. Looks like you found the issue and fixed it. Thank you.
Thank you, Rob!
#25 Updated by Andriy Lesyuk over 12 years ago
- Status changed from In Progress to Closed
#26 Updated by Rob Landry over 12 years ago
Very welcome. Thank you for the plugin. Now if i could only get some of your other plugins working like open id fix...