Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Rails 7 #7196

Closed
thanhtoan1196 opened this issue Nov 22, 2021 · 40 comments
Closed

Support Rails 7 #7196

thanhtoan1196 opened this issue Nov 22, 2021 · 40 comments

Comments

@thanhtoan1196
Copy link

Can't install activeadmin using rails 7.0.0.alpha2, please help

Logs

Fetching gem metadata from https://rubygems.org/.........
Resolving dependencies....
Bundler could not find compatible versions for gem "actionpack":
  In snapshot (Gemfile.lock):
    actionpack (= 7.0.0.alpha2)

  In Gemfile:
    activeadmin was resolved to 0.4.0, which depends on
      meta_search (>= 0.9.2) was resolved to 1.1.0.pre2, which depends on
        actionpack (~> 3.1.0.alpha)

    rails (~> 7.0.0.alpha2) was resolved to 7.0.0.alpha2, which depends on
      actionpack (= 7.0.0.alpha2)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Bundler could not find compatible versions for gem "rails":
  In snapshot (Gemfile.lock):
    rails (= 7.0.0.alpha2)

  In Gemfile:
    activeadmin was resolved to 1.0.0.pre3, which depends on
      rails (< 5.0, >= 3.2)

    turbo-rails (>= 0.7.11) was resolved to 0.8.3, which depends on
      rails (>= 6.0.0)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

Bundler could not find compatible versions for gem "railties":
  In snapshot (Gemfile.lock):
    railties (= 7.0.0.alpha2)

  In Gemfile:
    activeadmin was resolved to 1.0.0.pre5, which depends on
      railties (< 5.1, >= 3.2)

    rails (~> 7.0.0.alpha2) was resolved to 7.0.0.alpha2, which depends on
      railties (= 7.0.0.alpha2)

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.
@Fivell
Copy link
Member

Fivell commented Dec 13, 2021

related #7175

tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 14, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 14, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 14, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 17, 2021
@tagliala
Copy link
Contributor

tagliala commented Dec 17, 2021

I'm trying to update activeadmin to use rails 7 (tagliala#1), but there are some blocking dependencies:

Non-blocking, but downgrade to an older versions without issues:

Non-blocking, but downgrade to an older versions with issues:

Check #7235

tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 17, 2021
@alejandroperea
Copy link
Contributor

alejandroperea commented Dec 18, 2021

It is not a blocker but in case we are not able to update db-query-matchers I've created a PR for getting rid of it: #7232

@ciscolive
Copy link

can team update to rubygem ?

@tagliala
Copy link
Contributor

I've updated my comment above by adding arbre, that does not allow 7.0 and so it downgrades to 1.2.1

@javierjulio javierjulio changed the title support rails 7.0.0.alpha2 Support Rails 7 Dec 21, 2021
@baarkerlounger
Copy link

Looks like this branch has issues with the number of args in paginate here https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/views/components/paginated_collection.rb#L111

@tagliala
Copy link
Contributor

tagliala commented Dec 21, 2021

Looks like this branch has issues with the number of args in paginate here https://github.com/activeadmin/activeadmin/blob/master/lib/active_admin/views/components/paginated_collection.rb#L111

Thanks, will check

edit: I don't know how to replicate (Rails 7.0, Ruby 3.0.3). Is this about pagination in active admin views?

image

This issue will probably be discovered when it will be possible to run specs on activeadmin

tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 21, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 21, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 21, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 21, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 21, 2021
@tagliala tagliala mentioned this issue Dec 21, 2021
11 tasks
@tagliala
Copy link
Contributor

tagliala commented Dec 21, 2021

For tracking purposes and to prevent new PRs (edit: I mean new PRs just relaxing the dependency), I opened #7235

@missy-davies
Copy link

Hi @tagliala, I'd love to help with the effort to make ActiveAdmin compatible with Rails 7. Is there any piece of the puzzle I can take on?

@tagliala
Copy link
Contributor

Hi @missy-davies

Is there any piece of the puzzle I can take on?

Yes, feel free to take a look at #7235, there is a "working" branch with failing specs (on CI) and cucumber features

@missy-davies
Copy link

Yes, feel free to take a look at #7235, there is a "working" branch with failing specs (on CI) and cucumber features

@tagliala Great, thank you! I'm still working on setting up a virtual machine to be able to clone the repo and run the tests, but once I can see what's failing I'll give it a shot.

tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 24, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 24, 2021
tagliala added a commit to tagliala/activeadmin that referenced this issue Dec 24, 2021
Also:
- Update bundles
- Strengthen jasmine dependency to prevent deprecation errors
- Strengthen pry dependency to prevent deprecation errors

Close activeadmin#7196
@muaaz-vf
Copy link

Thank @tagliala adding the above gems does work but whenever we change the code in dev env there is an error afterward,

09:53:56 web.1 | ArgumentError (wrong number of arguments (given 2, expected 5)):
09:53:56 web.1 |
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/instrumenter.rb:62:in initialize' 09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/server_timing.rb:16:in new'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/server_timing.rb:16:in block in call' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:225:in publish'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:80:in block in publish' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:91:in block in iterate_guarding_exceptions'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:90:in each' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:90:in iterate_guarding_exceptions'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications/fanout.rb:80:in publish' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/notifications.rb:197:in publish'
09:53:56 web.1 | activeadmin (12ef798) lib/active_admin/application.rb:115:in load!' 09:53:56 web.1 | activeadmin (12ef798e1a02) lib/active_admin/application.rb:228:in block (2 levels) in attach_reloader'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:445:in instance_exec' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:445:in block in make_lambda'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:199:in block (2 levels) in halting' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:687:in block (2 levels) in default_terminator'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:686:in catch' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:686:in block in default_terminator'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:200:in block in halting' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:595:in block in invoke_before'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:595:in each' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:595:in invoke_before'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:106:in run_callbacks' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/reloader.rb:88:in prepare!'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/reloader.rb:47:in block in <class:Reloader>' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:445:in instance_exec'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:445:in block in make_lambda' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:271:in block in simple'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:599:in block in invoke_after' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:599:in each'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:599:in invoke_after' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/callbacks.rb:108:in run_callbacks'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/execution_wrapper.rb:133:in run' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/execution_wrapper.rb:129:in run!'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/reloader.rb:114:in run!' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/execution_wrapper.rb:74:in block in run!'
09:53:56 web.1 | internal:kernel:90:in tap' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/execution_wrapper.rb:71:in run!'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/reloader.rb:63:in run!' 09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/executor.rb:12:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in call' 09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:28:in call'
09:53:56 web.1 | web-console (4.2.0) lib/web_console/middleware.rb:132:in call_app' 09:53:56 web.1 | web-console (4.2.0) lib/web_console/middleware.rb:28:in block in call'
09:53:56 web.1 | web-console (4.2.0) lib/web_console/middleware.rb:17:in catch' 09:53:56 web.1 | web-console (4.2.0) lib/web_console/middleware.rb:17:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/show_exceptions.rb:26:in call' 09:53:56 web.1 | railties (7.0.0) lib/rails/rack/logger.rb:36:in call_app'
09:53:56 web.1 | railties (7.0.0) lib/rails/rack/logger.rb:25:in block in call' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/tagged_logging.rb:99:in block in tagged'
09:53:56 web.1 | activesupport (7.0.0) lib/active_support/tagged_logging.rb:37:in tagged' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/tagged_logging.rb:99:in tagged'
09:53:56 web.1 | railties (7.0.0) lib/rails/rack/logger.rb:25:in call' 09:53:56 web.1 | sprockets-rails (3.4.2) lib/sprockets/rails/quiet_assets.rb:13:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/remote_ip.rb:93:in call' 09:53:56 web.1 | request_store (1.5.0) lib/request_store/middleware.rb:19:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/request_id.rb:26:in call' 09:53:56 web.1 | rack (2.2.3) lib/rack/method_override.rb:24:in call'
09:53:56 web.1 | rack (2.2.3) lib/rack/runtime.rb:22:in call' 09:53:56 web.1 | activesupport (7.0.0) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/server_timing.rb:20:in call' 09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/executor.rb:14:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/static.rb:23:in call' 09:53:56 web.1 | rack (2.2.3) lib/rack/sendfile.rb:110:in call'
09:53:56 web.1 | actionpack (7.0.0) lib/action_dispatch/middleware/host_authorization.rb:137:in call' 09:53:56 web.1 | railties (7.0.0) lib/rails/engine.rb:530:in call'
09:53:56 web.1 | puma (5.5.2) lib/puma/configuration.rb:249:in call' 09:53:56 web.1 | puma (5.5.2) lib/puma/request.rb:77:in block in handle_request'
09:53:56 web.1 | puma (5.5.2) lib/puma/thread_pool.rb:340:in with_force_shutdown' 09:53:56 web.1 | puma (5.5.2) lib/puma/request.rb:76:in handle_request'
09:53:56 web.1 | puma (5.5.2) lib/puma/server.rb:447:in process_client' 09:53:56 web.1 | puma (5.5.2) lib/puma/thread_pool.rb:147:in block in spawn_thread'

We have to restart the server and then all seems to work, any workaround will be appreciated. Plus thank you for your great effort.

@tagliala
Copy link
Contributor

Any chance to provide a step to step guide to reproduce this issue or a reproducible test case in a public repository?

@muaaz-vf
Copy link

Sure will share example and steps to produce it today thank you for quick reply.

@tagliala
Copy link
Contributor

Sure will share example and steps to produce it today thank you for quick reply.

No need, reproduced thanks!

@tagliala
Copy link
Contributor

@muaaz-vf could you please try to disable server_timing ?

diff --git a/config/environments/development.rb b/config/environments/development.rb
index 62354ff..916e29d 100644
--- a/config/environments/development.rb
+++ b/config/environments/development.rb
@@ -17,7 +17,7 @@ Rails.application.configure do
   config.consider_all_requests_local = true
 
   # Enable server timing
-  config.server_timing = true
+  # config.server_timing = true
 
   # Enable/disable caching. By default caching is disabled.
   # Run rails dev:cache to toggle caching.

@muaaz-vf
Copy link

Thank you much appreciated, anyway I can buy you a cup of coffee :)

@nquocvuong
Copy link

Hi @tagliala

in my gemfile:

gem 'activeadmin', github: 'tagliala/activeadmin', branch: 'feature/railties-7' # FIXME: revert to stable

gem 'arbre', github: 'activeadmin/arbre' # FIXME: remove
gem 'inherited_resources', github: 'activeadmin/inherited_resources' # FIXME: remove

and in config/initializers/active_admin.rb

...
  config.before_action :abc
...

then I got this error:

/lib/active_admin/base_controller/authorization.rb:3:in `<module:ActiveAdmin>': uninitialized constant InheritedResources::Base (NameError)
Did you mean?  Base64

if I remove config.before_action, it work

@tagliala
Copy link
Contributor

tagliala commented Jan 6, 2022

then I got this error:

/lib/active_admin/base_controller/authorization.rb:3:in `<module:ActiveAdmin>': uninitialized constant InheritedResources::Base (NameError)
Did you mean?  Base64

Replicated, thanks

edit: This is related to autoloading. I do not know hot to fix, but I've added a checkbox to known issues at #7235

tagliala added a commit to tagliala/activeadmin that referenced this issue Jan 18, 2022
Also:
- Update bundles
- Strengthen jasmine dependency to prevent deprecation warnings
- Strengthen pry dependency to prevent deprecation warnings

Close activeadmin#7196
tagliala added a commit to tagliala/activeadmin that referenced this issue Jan 19, 2022
Also:
- Update bundles
- Strengthen jasmine dependency to prevent deprecation warnings
- Strengthen pry dependency to prevent deprecation warnings

Close activeadmin#7196
tagliala added a commit to tagliala/activeadmin that referenced this issue Jan 20, 2022
Also:
- Update bundles
- Strengthen jasmine dependency to prevent deprecation warnings
- Strengthen pry dependency to prevent deprecation warnings

Close activeadmin#7196
@elliotcm
Copy link

then I got this error:

/lib/active_admin/base_controller/authorization.rb:3:in `<module:ActiveAdmin>': uninitialized constant InheritedResources::Base (NameError)
Did you mean?  Base64

Replicated, thanks

edit: This is related to autoloading. I do not know hot to fix, but I've added a checkbox to known issues at #7235

@tagliala After much digging, I suspect this is due to the issue mentioned in the callout box here:
https://guides.rubyonrails.org/configuring.html#using-initializer-files

My app loads OK after wrapping the contents of config/initializers/active_admin.rb in a Rails.application.config.after_initialize do block.

@tagliala
Copy link
Contributor

Hi @elliotcm, thanks for the feedback

That fix can be addressed in a separate PR like #7262

I'm not going to create such a PR because I don't know the possible side effects

@elliotcm
Copy link

elliotcm commented Jan 23, 2022

Hi @elliotcm, thanks for the feedback

That fix can be addressed in a separate PR like #7262

I'm not going to create such a PR because I don't know the possible side effects

@tagliala Yes I'm not sure there's a fix you can make in the gem(s), but it's a workaround at least for others. It might even go away when we're not loading the inherited resources gem directly, I'm not savvy enough with the exact timing of Rails loading stuff to be able to suggest a permanent fix.

One reason I wouldn't suggest baking it in to activeadmin is that by moving the activeadmin setup to after_initialize, it is set up after controllers are loaded (when eager loading in production), so any before_actions that you create via the activeadmin config aren't available in the controllers at the time of processing.

In other words, I have this in my AA config:

    config.before_action :enforce_2sv

and I previously had this in my sessions controller:

class Admin::SessionsController < ActiveAdmin::Devise::SessionsController
  skip_before_action :enforce_2sv
end

but I've now had to move that to the end of the after_initialize block so it happens after AA is set up (so that the action exists to be skipped).

Admin::SessionsController.skip_before_action(:enforce_2sv)

Quite convoluted but hopefully helps other people get going while things are fixed properly.

@KevinBongart
Copy link

@tagliala @deivid-rodriguez Since #7235 was merged yesterday (excellent work!), should we consider ActiveAdmin Rails-7 ready and, if so, release a new version?

If not: what's left and where can I find more information about the remaining work? Happy to help.

@deivid-rodriguez
Copy link
Member

I will release a Rails 7 compatible version next Friday.

I'll close this issue since it was indeed fixed by #7235!

@jadelekekpmg
Copy link

Thank you so much for resolving this issue. I have been watching it since December.
Appreciate your efforts: @tagliala @deivid-rodriguez

@arhaikal
Copy link

arhaikal commented Apr 10, 2022

Trying to upgrade to rails 7,
I am running activeadmin 2.11.1 which i think is the latest version but i am still getting the following error:

uninitialized constant InheritedResources::Base (NameError) Did you mean? Base64

gem 'rails', '~> 7.0.0'
ruby '3.1.1'

anyone is still facing this problem?

@tagliala
Copy link
Contributor

I am running activeadmin 2.11.1 which i think is the latest version but i am still getting the following error:

uninitialized constant InheritedResources::Base (NameError) Did you mean? Base64

This issue should have been fixed by #7340

@arhaikal
Copy link

uninitialized constant InheritedResources::Base (NameError) Did you mean? Base64

This issue should have been fixed by #7340

That doesn't seem the case here as the error persists even after removing the before_action from the initializer.
I am still digging to see what is causing this, so i will make an update if i find something.

@arhaikal
Copy link

@tagliala I didn't find anything that i can change in my app to mitigate the problem. When the gem is added the error comes from

ruby-3.1.1/gems/activeadmin-2.11.1/lib/active_admin/base_controller/authorization.rb:3 which was already mentioned in the issue that you linked

@heyfadii
Copy link

heyfadii commented May 14, 2022

I'm having the exact same issue as @arhaikal using Version 2.13.0. I'm on ruby 2.7.4 / rails 7.

UPDATE:
I found out, that it was not the main activeadmin gem, but other gems: activeadmin-xls, activeadmin-reform that caused the error.

@antarr
Copy link

antarr commented May 20, 2022

I'm still getting this error when using ActiveAdmin::BaseController.include(ActiveAdmin::FiltersPersistance) which I got from here.

@tagliala
Copy link
Contributor

tagliala commented May 20, 2022

I'm still getting this error when using ActiveAdmin::BaseController.include(ActiveAdmin::FiltersPersistance) which I got from here.

Probably the problem is in

ActiveAdmin::BaseController.send(:include, ActiveAdmin::FiltersPersistance)

And it is not related to Rails Admin

Please try with

ActiveSupport.on_load(:active_admin_controller) do
  ActiveAdmin::BaseController.include ActiveAdmin::FiltersPersistance
end

Ref: #7340

@antarr
Copy link

antarr commented May 20, 2022

@tagliala Thanks, that fixed it

@ghulamjilani
Copy link

ghulamjilani commented Jan 18, 2023

@tagliala , @ALL I upgraded my rails version from 6.1 to 7 but facing the following issue related to activeadmin.
I have Implemented many solutions including Rails.application.config.after_initialize do
But, still it is throwing this error..

uninitialized constant InheritedResources::Base (NameError)

  class BaseController < ::InheritedResources::Base
                                             ^^^^^^
Did you mean?  Base64

@tagliala
Copy link
Contributor

@ghulamjilani mai depend on other gems, please check the latest comments in this thread and #7340

Rails.application.config.after_initialize

The proper solution should involve ActiveSupport.on_load(:active_admin_controller) but this may not depend by ActiveAdmin itself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests