# Rails 7 Madness: No such middleware to insert before: ActionDispatch::Static

DevFeed: [Rails 7 Madness: No such middleware to insert before: ActionDispatch::Static](<https://devfeed.tech/articles/rails-7-madness-no-such-middleware-to-insert-before-actiondispatch-static-28277.md>)

Original publisher: [Read original article](<http://fuzzyblog.io/blog/rails/2022/06/02/rails-7-madness-no-such-middleware-to-insert-before-actiondispatch-static.html>)

Author: Fuzzygroup

Published: 2022-06-02T04:22:00Z

Content type: tutorial

Language: en

Sources: [Scott Johnson](<https://devfeed.tech/sources/scott-johnson.md>)

Topics: [Rails](<https://devfeed.tech/topics/rails.md>), [Vite](<https://devfeed.tech/topics/vite.md>), [Ruby](<https://devfeed.tech/topics/ruby.md>), [npm packages](<https://devfeed.tech/topics/npm-packages.md>)

Tags: [deploy](<https://devfeed.tech/tags/deploy.md>), [errors](<https://devfeed.tech/tags/errors.md>), [hatchbox](<https://devfeed.tech/tags/hatchbox.md>), [logging](<https://devfeed.tech/tags/logging.md>), [npm-packages](<https://devfeed.tech/tags/npm-packages.md>), [rails](<https://devfeed.tech/tags/rails.md>), [rake](<https://devfeed.tech/tags/rake.md>), [troubleshooting](<https://devfeed.tech/tags/troubleshooting.md>), [vite](<https://devfeed.tech/tags/vite.md>)

## AI overview

A troubleshooting account of a Rails 7 deployment error reporting that no middleware could be inserted before ActionDispatch::Static. The author reproduced the issue with Rails commands, added the smart_assets gem, and then encountered a different deployment failure indicating that the Vite binary was unavailable.

## Source excerpt

In tonight's category of "Crazy Rails Errors that Even I haven't hit", I was deploying a new app via HatchBox and I hit this one: No such middleware to insert before: ActionDispatch::Static /home/deploy/Cartazzi/shared/bundle/ruby/3.1.0/gems/actionpack-7.0.2.2/lib/action_dispatch/middleware/stack.rb:174:in `assert_index' When I dug into the underlying failure there was this bit of code: def assert_index(index, where) i = index.is_a?(Integer) ? index : index_of(index) raise "No such middleware to insert #{where}: #{index.inspect}" unless i i end I did the obligatory googling only to find nothing in the past year and absolutely nothing related to Rails 7. I was able to replicate this by logging in with either: bundle exec rake middleware or RAILS_ENV=production bundle exec rake assets:precompile After stumbling around a bit - this was post midnight late night code fu - I thoguht to myself: What if the issue is that it is looking for middleware and it can't find any? One of the previous googles from 2015 or so said that if you have this issue then remove the font_assets gem (I didn't have it but omitted that part of the research above). What I did was look for asset pipeline middleware and I found the smart_assets gem which I dropped into Gemfile: gem 'smart_assets' A quick bundle install and I ended up with a failing deploy ... but a different failure: Building with Vite rake aborted! ViteRuby::MissingExecutableError: The vite binary is not available. Have you installed the npm packages? Visit the Troubleshooting guide for more information: https://vite-ruby.netlify.app/guide/troubleshooting.html#troubleshooting And that, in modern computing, alas, is progress.