thoughtbot / administrate

A Rails engine that helps you put together a super-flexible admin dashboard.
http://administrate-demo.herokuapp.com
MIT License
5.87k stars 1.11k forks source link

Not installed properly (at all) #2357

Closed CurlyBastard closed 1 year ago

CurlyBastard commented 1 year ago

Greeting everyone! trying to run rails g administrate:install and get this:

route  namespace :admin do

                  resources :users
                  resources :doctors

                  root to: "users#index"
                end
WARNING: Unable to generate a dashboard for ActionMailbox::InboundEmail.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
WARNING: Unable to generate a dashboard for ActiveStorage::Attachment.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
WARNING: Unable to generate a dashboard for ActiveStorage::Blob.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
WARNING: Unable to generate a dashboard for ActiveStorage::VariantRecord.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
WARNING: Unable to generate a dashboard for ActionText::RichText.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
WARNING: Unable to generate a dashboard for ActionText::EncryptedRichText.
       - Administrate does not yet support namespaced models.
       - It is not connected to a database table.
         Make sure your database migrations are up to date.
      create  app/controllers/admin/application_controller.rb
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/administrate/namespace.rb:9:in `block in resources': uninitialized constant Administrate::Namespace::Resource (NameError)
from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/administrate/namespace.rb:8:in `map'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/administrate/namespace.rb:8:in `resources'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/generators/administrate/install/install_generator.rb:57:in `dashboard_resources'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/generators/administrate/install/install_generator.rb:53:in `singular_dashboard_resources'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/generators/administrate/install/install_generator.rb:34:in `run_dashboard_generators'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `block in invoke_all'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `each'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `map'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:134:in `invoke_all'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/group.rb:232:in `dispatch'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/base.rb:485:in `start'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/generators.rb:263:in `invoke'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands/generate/generate_command.rb:26:in `perform'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/base.rb:87:in `perform'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command.rb:48:in `invoke'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands.rb:18:in `<main>'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
    from /Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
    from bin/rails:4:in `<main>' 

Then I tried to rails destroy administrate:install to undo this and got:

    >[WARNING] Could not load generator "generators/administrate/install/install_generator". Error: uninitialized constant Admin::Administrate.
/Users/curlybastard/clinic/clinicapp/clinicapp/app/controllers/admin/application_controller.rb:8:in `<module:Admin>'
/Users/curlybastard/clinic/clinicapp/clinicapp/app/controllers/admin/application_controller.rb:7:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:30:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:135:in `cget'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:169:in `block in actual_eager_load_dir'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:25:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:25:in `ls'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:164:in `actual_eager_load_dir'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:16:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:297:in `block in eager_load_all'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:295:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:295:in `eager_load_all'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/administrate-0.18.0/lib/generators/administrate/install/install_generator.rb:2:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:44:in `block (2 levels) in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:40:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:40:in `block in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:39:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:39:in `lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/generators.rb:245:in `find_by_namespace'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/generators.rb:261:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands/destroy/destroy_command.rb:24:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/base.rb:87:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command.rb:48:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands.rb:18:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
bin/rails:4:in `<main>'
Could not find generator 'administrate:install'.
Did you mean?  administrate:field
Run `bin/rails generate --help` for more options.<

Have a freaking headache. Any help will be much appreciated.

p.s. sorry for incorrect structure of post, can't figure it out, but hope it readable.

pablobm commented 1 year ago

That's odd. It appears to be some issue with the load order of files and classes. Would you be able to try out this branch to see if it also has this problem? https://github.com/thoughtbot/administrate/compare/main...pablobm:administrate:load-order

CurlyBastard commented 1 year ago

Guess, I would not decline some detailed instructions for how to try this, because I'm definitely not experienced enough yet.

littleforest commented 1 year ago

Try:

git fetch https://github.com/pablobm/administrate.git load-order:pablobm-load-order
git checkout pablobm-load-order

(Ref)

CurlyBastard commented 1 year ago

Try:

git fetch https://github.com/pablobm/administrate.git load-order:pablobm-load-order
git checkout pablobm-load-order

(Ref)

Thank you.

After bundle install I ran same first command rails g administrate:install , and got:

warning: parser/current is loading parser/ruby30, which recognizes3.0.4-compliant syntax, but you are running 3.0.0.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
Deprecation warning: Expected string default value for '--javascript-engine'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
Could not find generator 'administarte:install'. Maybe you meant "administrate:assets"?
Run `bin/rails generate --help` for more options.
littleforest commented 1 year ago

From the error message, it looks like you had a typo with the install command:

Could not find generator 'administarte:install'. Maybe you meant "administrate:assets"?

Are you sure you did rails g administrate:install and not rails g administarte:install ?

CurlyBastard commented 1 year ago

From the error message, it looks like you had a typo with the install command:

Could not find generator 'administarte:install'. Maybe you meant "administrate:assets"?

Are you sure you did rails g administrate:install and not rails g administarte:install ?

You're absolutely right, there was a typo. I fix it, run command correctly, and here's result:

warning: parser/current is loading parser/ruby30, which recognizes3.0.4-compliant syntax, but you are running 3.0.0.
Please see https://github.com/whitequark/parser#compatibility-with-ruby-mri.
[WARNING] Could not load generator "generators/administrate/install/install_generator". Error: Cannot load database configuration:
Could not load database configuration. No such file - ["config/database.yml"].
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/application/configuration.rb:294:in `database_configuration'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.6.1/lib/active_record/railtie.rb:221:in `block (2 levels) in <class:Railtie>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:52:in `block in run_load_hooks'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:51:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/lazy_load_hooks.rb:51:in `run_load_hooks'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.6.1/lib/active_record/base.rb:315:in `<module:ActiveRecord>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activerecord-6.1.6.1/lib/active_record/base.rb:15:in `<top (required)>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `block in require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:297:in `block in load_dependency'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:715:in `new_constants_in'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:297:in `load_dependency'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
/Users/curlybastard/clinic/clinicapp/clinicapp/spec/example_app/app/models/application_record.rb:1:in `<top (required)>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `block in load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:715:in `new_constants_in'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:522:in `load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:419:in `block in require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `block in load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:402:in `require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:558:in `load_missing_constant'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:213:in `const_missing'
/Users/curlybastard/clinic/clinicapp/clinicapp/spec/example_app/app/models/customer.rb:1:in `<top (required)>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `block in load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:715:in `new_constants_in'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:522:in `load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:419:in `block in require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `block in load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:402:in `require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:558:in `load_missing_constant'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:213:in `const_missing'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:595:in `load_missing_constant'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:213:in `const_missing'
/Users/curlybastard/clinic/clinicapp/clinicapp/spec/example_app/app/dashboards/customer_dashboard.rb:14:in `<class:CustomerDashboard>'
/Users/curlybastard/clinic/clinicapp/clinicapp/spec/example_app/app/dashboards/customer_dashboard.rb:4:in `<top (required)>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:523:in `block in load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:715:in `new_constants_in'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:522:in `load_file'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:419:in `block in require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `block in load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:14:in `block in loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies/interlock.rb:13:in `loading'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:39:in `load_interlock'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:402:in `require_or_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:375:in `depend_on'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:288:in `require_dependency'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/engine.rb:493:in `block (2 levels) in eager_load!'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/engine.rb:492:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/engine.rb:492:in `block in eager_load!'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/engine.rb:489:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/engine.rb:489:in `eager_load!'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/application.rb:519:in `eager_load!'
/Users/curlybastard/clinic/clinicapp/clinicapp/lib/generators/administrate/install/install_generator.rb:4:in `<top (required)>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `block in require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:299:in `load_dependency'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/behavior.rb:44:in `block (2 levels) in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/behavior.rb:40:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/behavior.rb:40:in `block in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/behavior.rb:39:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/behavior.rb:39:in `lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/generators.rb:257:in `find_by_namespace'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/generators.rb:273:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/commands/generate/generate_command.rb:26:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command/base.rb:69:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/command.rb:48:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-6.1.6.1/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:5:in `require'
bin/rails:5:in `<main>'
Deprecation warning: Expected string default value for '--javascript-engine'; got false (boolean).
This will be rejected in the future unless you explicitly pass the options `check_default_type: false` or call `allow_incompatible_default_type!` in your code
You can silence deprecations warning by setting the environment variable THOR_SILENCE_DEPRECATION.
Could not find generator 'administrate:install'. Maybe you meant "administrate:field"?
Run `bin/rails generate --help` for more options.
littleforest commented 1 year ago

Could not load database configuration. No such file - ["config/database.yml"]

Do you have a config/database.yml file in your project?

CurlyBastard commented 1 year ago

No, I have not.

littleforest commented 1 year ago

Outside of trying to get Administrate set up, do you have at least a bare bones Rails app set up working? It seems that you still have some general Rails configuration to do if you don't have a config/database.yml file. Sometimes the config/database.yml file is not stored in the repo and you need to copy over a config/database.yml.example file to config/database.yml, depending on how your project is structured.

pablobm commented 1 year ago

Apologies for the confusion @CurlyBastard. Would you be able to change the line gem "administrate" to the following in your Gemfile?

# Gemfile
gem "administrate", git: "https://github.com/pablobm/administrate", branch: "load-order"

This will use my branch load-order in your app. Then you can see if the problem still persists. After that, you can undo the change and go back to just gem "administrate" (or whatever you had before).

CurlyBastard commented 1 year ago

I can, but should I do this from my main branch, or from that I recently changed to, as @littleforest mentioned above? Because I'm currently on * pablobm-load-order

pablobm commented 1 year ago

Sorry, what I mean is that you do this on your own app, the one that is giving you that error when you try to install.

CurlyBastard commented 1 year ago

No need to apologise, thank you for your involvement!

My actions: I changed branch to my main (where my app is), edited gemfile as you suggest, run bundle install, then rails g administrate:install, and got this:

[WARNING] Could not load generator "generators/administrate/install/install_generator". Error: uninitialized constant Admin::Administrate
Did you mean?  AdminUser.
/Users/curlybastard/clinic/clinicapp/clinicapp/app/controllers/admin/application_controller.rb:8:in `<module:Admin>'
/Users/curlybastard/clinic/clinicapp/clinicapp/app/controllers/admin/application_controller.rb:7:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:30:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:135:in `cget'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:169:in `block in actual_eager_load_dir'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:25:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/helpers.rb:25:in `ls'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:164:in `actual_eager_load_dir'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:16:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:297:in `block in eager_load_all'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:295:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/loader.rb:295:in `eager_load_all'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/bundler/gems/administrate-9f434a6d31ab/lib/generators/administrate/install/install_generator.rb:2:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/zeitwerk-2.6.7/lib/zeitwerk/kernel.rb:38:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:44:in `block (2 levels) in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:40:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:40:in `block in lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:39:in `each'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/behavior.rb:39:in `lookup'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/generators.rb:245:in `find_by_namespace'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/generators.rb:261:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands/generate/generate_command.rb:26:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command/base.rb:87:in `perform'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/command.rb:48:in `invoke'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/railties-7.0.4.3/lib/rails/commands.rb:18:in `<main>'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
/Users/curlybastard/.rvm/gems/ruby-3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
bin/rails:4:in `<main>'
Could not find generator 'administrate:install'.
Did you mean?  administrate:field
Run `bin/rails generate --help` for more options.

edit: Could this troubles also be connected with my previous experience with active_admin? Bc now I can't run migration:

== 20230417195531 DeviseCreateAdminUsers: migrating ===========================
-- create_table(:admin_users)
rails aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::DuplicateTable: ERROR:  relation "admin_users" already exists
/Users/curlybastard/clinic/clinicapp/clinicapp/db/migrate/20230417195531_devise_create_admin_users.rb:5:in `change'

Caused by:
ActiveRecord::StatementInvalid: PG::DuplicateTable: ERROR:  relation "admin_users" already exists
/Users/curlybastard/clinic/clinicapp/clinicapp/db/migrate/20230417195531_devise_create_admin_users.rb:5:in `change'

Caused by:
PG::DuplicateTable: ERROR:  relation "admin_users" already exists
/Users/curlybastard/clinic/clinicapp/clinicapp/db/migrate/20230417195531_devise_create_admin_users.rb:5:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
pablobm commented 1 year ago

That might be it. I had a look at ActiveAdmin's code, and I see that it defines Admin with metaprogramming. It looks like this affects the autoload. I was able to reproduce in a different way.

Does your Gemfile still have the gem "activeadmin" line? If so, can you try remove it?

If you need to run Administrate and ActiveAdmin in the same app, one of the two should be in a namespace that is not admin, or they may conflict. For example, if you change the Administrate namespace to be Manager (don't call it Administrate or you will have the same problem), do this:

  1. Change all the module Admin to module Manager.
  2. Change all the Admin::*Controller to Manager::*Controller.
  3. Move the Administrate files from app/controllers/admin to app/controllers/manager.

Does any of this help?

CurlyBastard commented 1 year ago

I have replaced gem "activeadmin" by gem "administrate" previously, and currently my gemfile looks like this:

source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }

ruby "3.0.0"

gem "rails", "~> 7.0.4", ">= 7.0.4.2"

gem "sprockets-rails"

gem "pg", "~> 1.1"

gem "puma", "~> 5.0"

gem "jsbundling-rails"

gem "turbo-rails"

gem "stimulus-rails"

gem "cssbundling-rails"

gem "jbuilder"

gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]

gem "bootsnap", require: false

gem 'i18n', '~> 1.12'

group :development, :test do
  gem "debug", platforms: %i[ mri mingw x64_mingw ]
end

group :development do
  gem "web-console"

end

group :test do
  gem "capybara"
  gem "selenium-webdriver"
  gem "webdrivers"
end

group :administration do
  gem "devise"
  gem "administrate", git: "https://github.com/pablobm/administrate", branch: "load-order"
  gem "cancancan"
end

Is there some specific command to make changes you mentioned above? just to not to do it one-by-one, bc I have no idea where I may find "leftovers" of activeadmin.

I just want to do test task (pretty simple and popular one, btw) to land a job, ffs. Wish I had a tiny glimpse of circumstances...

CurlyBastard commented 1 year ago

Could not load database configuration. No such file - ["config/database.yml"]

Do you have a config/database.yml file in your project?

Little update On my main branch I have config/database.yml. Checked before switch back.

CurlyBastard commented 1 year ago

@pablobm, I just renamed everything I can find, but I still have this in my schema.rb:

create_table "admin_users", force: :cascade do |t|
    t.string "email", default: "", null: false
    t.string "encrypted_password", default: "", null: false
    t.string "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
    t.index ["email"], name: "index_admin_users_on_email", unique: true
    t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
  end

Would it possibly cause any conflicts? Should I do something with it by hand?

pablobm commented 1 year ago

Sorry, I forgot to also say something about the migration. Let's see...

You said that the migration DeviseCreateAdminUsers was failing. This is because of the early install of ActiveAdmin: the table admin_users exists in your DB, but Rails thinks that the migration hasn't run yet. So it tries to run it and it fails. That is what the error PG::DuplicateTable: ERROR: relation "admin_users" already exists means.

Do you need that table? If you don't, then you should remove the migration to simplify.

After that, regardless of whether you have removed the migration or not, perhaps you should run rails db:migrate:reset. This will destroy the DB and then run all migrations from the start. This will leave your DB in a "clean" state. Does that work for you?

If you don't want to destroy the DB, then don't worry: just remove the migration file. The table will stay in your DB, but you can ignore it.

pablobm commented 1 year ago

I contacted @CurlyBastard and had a look at his issue. He also had a model called Admin, which may also have interfered. I wonder if there's something we can do to detect/avoid these cases, but it will be tricky. For now, I'm just closing this issue.

In any case, remember that you can use Administrate without the generator (which is what failed here). In that case, you'll have to create the routes, controllers, and dashboards manually.