administrate icon indicating copy to clipboard operation
administrate copied to clipboard

Support for Propshaft

Open nickcharlton opened this issue 1 year ago • 6 comments

I've been working on Rails 8.0 support in #2705.

Rails 8.0 ships Propshaft as the default way to deliver assets in Rails, but Administrate assumes you're using sprockets, which has been the default for a long time. Propshaft has an upgrading guide which should be helpful.

I've heard of at least one report of a new thoughtbot client project (started this week or last) that's using Rails 8.0, using defaults with Propshaft has had a tricky time in getting Administrate up and running, but there's potentially more incompatibilities we should test with.

It'd be preferable if Administrate could support both options.

Related: #2514

nickcharlton avatar Nov 19 '24 10:11 nickcharlton

hi,

as coincidence has it, i just tried to install administrate for the first time in a brand new Rails 8.0.0.1 app but failed miserably with:

rails generate administrate:install
/home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/sprockets-rails-3.5.2/lib/sprockets/railtie.rb:106:in `block in <class:Railtie>': Expected to find a manifest file in `app/assets/config/manifest.js` (Sprockets::Railtie::ManifestNeededError)
But did not, please create this file and use it to link any assets that need
to be rendered by your app:

Example:
  //= link_tree ../images
  //= link_directory ../javascripts .js
  //= link_directory ../stylesheets .css
and restart your server

For more information see: https://github.com/rails/sprockets/blob/070fc01947c111d35bb4c836e9bb71962a8e0595/UPGRADING.md#manifestjs
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/initializable.rb:32:in `instance_exec'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/initializable.rb:32:in `run'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/initializable.rb:61:in `block in run_initializers'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:231:in `block in tsort_each'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:353:in `block (2 levels) in each_strongly_connected_component'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:434:in `each_strongly_connected_component_from'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:352:in `block in each_strongly_connected_component'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:350:in `each'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:350:in `call'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:350:in `each_strongly_connected_component'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:229:in `tsort_each'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/tsort.rb:208:in `tsort_each'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/initializable.rb:60:in `run_initializers'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/application.rb:440:in `initialize!'
        from /home/loading/dev/ai/miracles-ai/miracles-ai-monolith/config/environment.rb:5:in `<main>'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/zeitwerk-2.7.1/lib/zeitwerk/core_ext/kernel.rb:34:in `require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/application.rb:416:in `require_environment!'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command/actions.rb:20:in `boot_application!'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/commands/generate/generate_command.rb:21:in `perform'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor/command.rb:28:in `run'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor/invocation.rb:127:in `invoke_command'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command/base.rb:178:in `invoke_command'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/thor-1.3.2/lib/thor.rb:538:in `dispatch'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command/base.rb:73:in `perform'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command.rb:65:in `block in invoke'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command.rb:143:in `with_argv'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/command.rb:63:in `invoke'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/railties-8.0.1/lib/rails/commands.rb:18:in `<main>'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/3.3.0/bundled_gems.rb:69:in `block (2 levels) in replace_require'
        from /home/loading/.rbenv/versions/3.3.6/lib/ruby/gems/3.3.0/gems/bootsnap-1.18.4/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
        from bin/rails:4:in `<main>'

i cant go back to sprockets, so i guess i wont be able to use administrate but i just wanted you to know there are users out there without sprockets and the base is about to grow, given rails having propshaft as default now.

thanks for considering a change.

thisIsLoading avatar Feb 11 '25 06:02 thisIsLoading

Not sure if this helps, but the beta works with out sprockets which is what I'm using

alexanderholder avatar Feb 11 '25 06:02 alexanderholder

@alexanderholder cant thank you enough. the beta works!

i didnt even care to look for one as 0.20.1 was released just a couple days ago. or so i thought! it was actually 2024, so more than a year ago. thanks for correcting that misconception as well :)

thisIsLoading avatar Feb 11 '25 06:02 thisIsLoading

@sasaharukimedes I don't think your error is related to this issue. Probably best to keep this thread clear for discussion related to the original request. You could try open another issue and see if someone can help you there but I believe your issue may actually be related to propshaft. You could try the rails assets clobber command as it sounds like a build issue but again, it would be better to create a new GitHub issue and post more info to be sure.

alexanderholder avatar Feb 11 '25 10:02 alexanderholder

@thisIsLoading im glad i could help! I might add that i believe you can actually use a non beta release and not move your project to sprockets. The only thing you should need to do is add a blank manifest file in that assets directory mentioned in the error. I haven't tested if a compiled build would work, but it did work in dev. Just something you could look into if you prefer to not use a beta release.

alexanderholder avatar Feb 11 '25 10:02 alexanderholder

@alexanderholder

I'm sorry for make not clean this issue, but thank you so much for gentle comment. I deleted previous my comment.

After rails assets:clobber command, bin/dev command works! Thank you for helping me!

sasaharukimedes avatar Feb 11 '25 10:02 sasaharukimedes

@nickcharlton - Is there anything to do on this issue? Is this about testing with some real Rails 8 apps until we are confident enough that we have this covered?

pablobm avatar Jun 20 '25 14:06 pablobm

It's just testing it works properly with Rails 8 + Propshaft.

nickcharlton avatar Jun 20 '25 15:06 nickcharlton

I had a go at integrating Administrate in https://github.com/pablobm/rubyevents, which is an open source app that uses Rails 8 and generally tries to stick to The Rails Way.

With regard to testing Administrate with Rails 8, it went well. I have put together a PR with notes at https://github.com/pablobm/rubyevents/pull/1 (This is just for this experiment's purposes, not to be actually merged into the actual upstream app).

pablobm avatar Jun 24 '25 14:06 pablobm

I think with the v1.0.0 beta's there's no difference. I've built and worked with several Rails apps since opening this and everything just works as expected. As it's the new default in Rails 8, I've got to take that to mean that this is working exactly as expected.

Which is nice, because we can close it!

nickcharlton avatar Oct 07 '25 13:10 nickcharlton