comfy / comfortable-mexican-sofa

ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
MIT License
2.73k stars 638 forks source link

RuntimeError (Circular dependency detected while autoloading constant Admin::Cms::BaseController): #441

Closed barnett closed 10 years ago

barnett commented 10 years ago

I just developed a project locally and am pushing to Heroku when I received this error after pushing/migrating. The error has the follow trace, any ideas?

vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:461:in `load_missing_constant'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:184:in `const_missing'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:228:in `const_get'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:228:in `block in constantize'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `each'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `inject'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `constantize'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:535:in `get'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:566:in `constantize'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:66:in `controller'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:44:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:71:in `block in call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `each'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:680:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/request_store-1.0.5/lib/request_store/middleware.rb:9:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/flash.rb:241:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/cookies.rb:486:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/query_cache.rb:36:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in `_run__2502564956568862695__call__callbacks'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:38:in `call_app'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `block in call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:25:in `tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
201

vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:461:in `load_missing_constant'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:184:in `const_missing'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:228:in `const_get'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:228:in `block in constantize'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `each'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `inject'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/inflector/methods.rb:224:in `constantize'
2014-04-03T16:41:11.303104+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:535:in `get'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:566:in `constantize'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:76:in `controller_reference'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:66:in `controller'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:44:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:71:in `block in call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `each'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/journey/router.rb:59:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/routing/route_set.rb:680:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/request_store-1.0.5/lib/request_store/middleware.rb:9:in `call'
2014-04-03T16:41:11.303298+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:35:in `block in call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `catch'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/warden-1.2.3/lib/warden/manager.rb:34:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/etag.rb:23:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/conditionalget.rb:25:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/head.rb:11:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/params_parser.rb:27:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/flash.rb:241:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:225:in `context'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/session/abstract/id.rb:220:in `call'
2014-04-03T16:41:11.303460+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/cookies.rb:486:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/query_cache.rb:36:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:373:in `_run__2502564956568862695__call__callbacks'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/callbacks.rb:80:in `run_callbacks'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
2014-04-03T16:41:11.303966+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:38:in `call_app'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `block in call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `block in tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:25:in `tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/tagged_logging.rb:67:in `tagged'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/rack/logger.rb:20:in `call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.2/lib/action_dispatch/middleware/request_id.rb:21:in `call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/methodoverride.rb:21:in `call'
2014-04-03T16:41:11.304155+00:00 app[web.1]:   vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/runtime.rb:17:in `call'
GBH commented 10 years ago

What version is that? Not seeing anything cms related in the stack trace.

barnett commented 10 years ago

1.11.2

GBH commented 10 years ago

Definitely not something with CMS as there are tons of them in production. 1.11.0 sample app is on Heroku. I can try bumping it and redeploying just to check, but I'm sure it should be fine. There are tons of hits on google about Circular+dependency+detected+while+autoloading+constant Let me know what you find.

barnett commented 10 years ago

So here it mentions to have controllers for the backend inherit from Admin::Cms::BaseController. This worked well in development, yet I believe thus seems to be the error source in production.

GBH commented 10 years ago

I'm not sure what is happening, but is it possible that cms gem is not loaded for some reason during that? That's the only reason why Admin::Cms::BaseController not going to be accessible.

barnett commented 10 years ago

I used to have the controllers local so that made sense so ended up deleting them so they use the gem but still errors. Ended up being able to access any scaffold model I did for the backend but cannot access the Pages/Layouts/Files/Sites pages. Here is the repo for the project. Any ideas?

GBH commented 10 years ago

You gotta give me access to the repo if you want me to check it out

barnett commented 10 years ago

@GBH its open now, thank you.

GBH commented 10 years ago

I can't see anything that sticks out. Locally your app loads and tests run.

I thought maybe there's something particular about Heroku environment. So I updated demo app and generated a scaffold to try it out. It got deployed and runs fine. Take a look: https://github.com/comfy/comfy-demo maybe it will give you a clue. I have no idea at the moment.

barnett commented 10 years ago

@GBH this is my routes/controller another warning I am seeing when I launch console in development. I feel like my routing is causing the problems?

GBH commented 10 years ago

I left a comment: https://gist.github.com/blklane/25d2e7f88527145c2533#comment-1209943 Does it help?

barnett commented 10 years ago

@GBH left another comment. I updated from the master but than got an error of an initialized constant to do with ComfyBlog. Then I set ComfyBlog to pull from master and still had the same error.

GBH commented 10 years ago

Ah yeah, blog is definitely going to be out of sync with cms at the moment. I'll have to update it as well.

barnett commented 10 years ago

So with keeping CMS at 1.11.2 and Blog at 1.1.1 (according to my Gemfile.lock) how am I able to fix this in the short term? I saw your link to that pull request, just unsure what exactly I should be doing since I only have some of the views over written, no controllers. And then what do I do with my controllers re-using the backend/authentication?

GBH commented 10 years ago

I think it's worth updating Blog to use same namespace as the master branch of CMS. I'll try to do this over the weekend. It's actually not a very complicated thing to do.

barnett commented 10 years ago

@GBH is there anyway I can fix it fix short-term quickly, just to launch over the weekend? Working on a non-profits site and they really wanted to start loading content today.

GBH commented 10 years ago

Super-short term: remove blog component for the time being.

barnett commented 10 years ago

Removing the blog gem/routes/initializer also stopped the issue this ticket is originally for! Thank you so much @GBH

GBH commented 10 years ago

@blklane about the blog component. Give 1.12 branch a try. It should theoretically work with current master branch CMS.

barnett commented 10 years ago

@GBH, set my gem for that branch, and now receiving an error uninitialized constant Comfy::Admin::Cms and have the following routes:

Cwi::Application.routes.draw do

  mount RailsEmailPreview::Engine, at: 'admin/emails'
  comfy_route :blog_admin, :path => '/admin'
  comfy_route :blog, :path => '/blog'

  namespace :admin do
    # ....
    resources :maps, :endorsements, :users, :stories, :campaigns, :projects, :employee_profiles
  end

  devise_for :users
  comfy_route :cms_admin, :path => '/admin'
  root :to => "cms/content#show"
  # Make sure this routeset is defined last
  comfy_route :cms, :path => '/', :sitemap => false

end

Any idea why that's coming up?