spring icon indicating copy to clipboard operation
spring copied to clipboard

How to debug "already initialized constant" warnings

Open brauliobo opened this issue 8 years ago • 2 comments

I'm having several of them with spring (any without):

~/P/n/noosfero ❯❯❯ time bin/rake test test/unit/link_article_test.rb                                                                                                       ⏎noosfero ⬆ ✭ ✱ ◼
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:32: warning: already initialized constant Environment::IDENTIFY_SCRIPTS
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:32: warning: previous definition of IDENTIFY_SCRIPTS was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:45: warning: already initialized constant Environment::NUMBER_OF_BOXES
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:45: warning: previous definition of NUMBER_OF_BOXES was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:439: warning: already initialized constant Environment::DEFAULT_FEATURES
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/environment.rb:439: warning: previous definition of DEFAULT_FEATURES was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:23: warning: already initialized constant Profile::SEARCHABLE_FIELDS
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:23: warning: previous definition of SEARCHABLE_FIELDS was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:29: warning: already initialized constant Profile::SEARCH_FILTERS
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:29: warning: previous definition of SEARCH_FILTERS was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:34: warning: already initialized constant Profile::NUMBER_OF_BOXES
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:34: warning: previous definition of NUMBER_OF_BOXES was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:306: warning: already initialized constant Profile::IDENTIFIER_FORMAT
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:306: warning: previous definition of IDENTIFIER_FORMAT was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:309: warning: already initialized constant Profile::RESERVED_IDENTIFIERS
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:309: warning: previous definition of RESERVED_IDENTIFIERS was here
/home/braulio/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/associations.rb:1694: warning: already initialized constant Profile::HABTM_Kinds
/home/braulio/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activerecord-4.2.8/lib/active_record/associations.rb:1694: warning: previous definition of HABTM_Kinds was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:391: warning: already initialized constant Profile::LOCATION_FIELDS
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/profile.rb:391: warning: previous definition of LOCATION_FIELDS was here
/home/braulio/Projects/noosfero-ecosol/noosfero/app/models/uploaded_file.rb:22: warning: already initialized constant UploadedFile::DBM_PRIVATE_FILE

The project is opensource and is hosted at https://github.com/noosfero/noosfero

brauliobo avatar Mar 14 '17 01:03 brauliobo

Having very similar errors, and no ideas for solutions. I've tried just about everything in the book. Mine are:

/Users/jonnorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/clusivity.rb:6: warning: already initialized constant ActiveModel::Validations::Clusivity::ERROR_MESSAGE
/Users/JonNorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/clusivity.rb:6: warning: previous definition of ERROR_MESSAGE was here
/Users/JonNorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/core_ext/load_error.rb:2: warning: already initialized constant LoadError::REGEXPS
/Users/jonnorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/core_ext/load_error.rb:2: warning: previous definition of REGEXPS was here
/Users/JonNorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/core_ext/load_error.rb:28: warning: already initialized constant MissingSourceFile
/Users/jonnorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/core_ext/load_error.rb:28: warning: previous definition of MissingSourceFile was here
/Users/jonnorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/numericality.rb:5: warning: already initialized constant ActiveModel::Validations::NumericalityValidator::CHECKS
/Users/JonNorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/numericality.rb:5: warning: previous definition of CHECKS was here
/Users/jonnorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/numericality.rb:9: warning: already initialized constant ActiveModel::Validations::NumericalityValidator::RESERVED_OPTIONS
/Users/JonNorstrom/.rbenv/versions/2.3.4/lib/ruby/gems/2.3.0/gems/activemodel-4.2.8/lib/active_model/validations/numericality.rb:9: warning: previous definition of RESERVED_OPTIONS was here
=> Booting WEBrick
=> Rails 4.2.8 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2017-06-21 10:53:05] INFO  WEBrick 1.3.1
[2017-06-21 10:53:05] INFO  ruby 2.3.4 (2017-03-30) [x86_64-darwin16]
[2017-06-21 10:53:05] INFO  WEBrick::HTTPServer#start: pid=1303 port=3000

So my server boots, but then I get a fatal at / exception reentered error when I visit localhost:3000.

jonnorstrom avatar Jun 21 '17 14:06 jonnorstrom

@jonnorstrom I have the same problem, but I solved it by reinstall bundler with the same version shown in Gemfile.lock BUNDLE_WITH.

reyesyang avatar Aug 01 '17 02:08 reyesyang