Has anyone see this…
I have 2-3 existing Stimulus controller (created previously). These load fine.
Today I created a couple new Stimulus controllers. But these are not being linked in <head> and, thus, not loading at all.
Here’s <head>:
What’s missing here are element_closer_controller.js, share_controller.js, full_screen_controller.js, and xxx_controller.js.
All of those were created today.
I’ve tried:
- Restarting
bin/dev
- Clearing the browser cache (and testing in an “icognito” window)
- Completely turning off my content security policy (
config/initializers/content_security_policy.rb)
Nothing.
I’m guessing I must have something mis-configured. Or something changed since I created those other Stimulus controllers. But what that is isn’t obvious to me at the moment.
Has anyone experienced this problem?
More information:
I just noticed this in the server log:
Importmap skipped missing path: controllers/full_screen_controller.js
Importmap skipped missing path: controllers/element_closer_controller.js
Importmap skipped missing path: controllers/share_controller.js
Importmap skipped missing path: controllers/xxx_controller.js
That explains why these are not showing up in <head>. But it’s still not clear why these specifically are “missing”.
P.S. When I physically delete the app/assets/javascript/controllers/xxx_controller.js the message:
Importmap skipped missing path: controllers/xxx_controller.js
Is not reported any longer. Suggesting something is seeing these files but reporting them as “missing”.

Additional digging points to importmaps being the cause.
bin/importmap json
{
"imports": {
"application": "/assets/application-bfcdf840.js",
"@hotwired/turbo-rails": "/assets/turbo.min-ad2c7b86.js",
"@hotwired/stimulus": "/assets/stimulus.min-4b1e420e.js",
"@hotwired/stimulus-loading": "/assets/stimulus-loading-1fc53fe7.js",
"controllers/application": "/assets/controllers/application-3affb389.js",
"controllers/date_and_time_validator_controller": "/assets/controllers/date_and_time_validator_controller-e1f29627.js",
"controllers/deleted_marker_controller": "/assets/controllers/deleted_marker_controller-0583adf0.js",
"controllers": "/assets/controllers/index-ee64e1f1.js",
"controllers/table_form_controller": "/assets/controllers/table_form_controller-d0ca5ed9.js"
}
}
This does not include the newest Stimulus controllers.

I suspect this may have something to do with the content_security_policy in config/initializers/content_security_policy.rb where these are set:
config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s }
config.content_security_policy_nonce_directives = %w(script-src style-src)
But what’s odd is that even when I completely turn off the CSP, it still doesn’t work.
This is getting more baffling.
I’m trying to walk through the importmap-rails code starting with javascript_importmap_tags (and trying to find my way down to resolve_asset_path where the warning appears to come from.)
The method javascript_importmap_tags starts with Rails.application.importmap which, when I look in the console, does have all of the Stimulus controllers.
This is baffling.
I figured it out.
For some reason there were pre-compiled assets under public/assets. I’m not sure how or when those were generated. It must have been after I created the previous Stimulus controller and before these new ones. They appeared to take precedence. So the new one were not getting picked up.
I resolved this issue by simply running bin/rails assets:clobber. This clears out public/assets. These pre-compiled assets do not appear to be getting regenerated. I’m not entirely sure how they were before. I have not directly run bin/rails assets:precompile so I’m still a bit confused.
Hey, just wanted to let you know that your self posting wasn’t in vain. I’ve enjoyed the tension and the resolution of your story.
Thank you for coming back to conclude the thread. Nothing is more frustrating than seeing someone else have the exact same problem as you and then see them post “solved” without explaining how.
And of course, there’s an XKCD for it: xkcd: Wisdom of the Ancients 
As for how it could have happened, AFAIK you had to run precompile at some point, perhaps accidentally or maybe indirectly (by accidentally running something else in production environment).
1 Like
Thanks. I appreciate that. I share the frustration of seeing someone post about and issue and never seeing the resolution to it.
Thanks also for the hints about what might have caused the pre-compile. I think I might have been messing with Kamal and its very likely that what did the precompile and I didn’t notice it at the time (and forgot since I did it).
All the best to you!