Assets say "not precompiled" when they are precompiled

Andrew picture Andrew · Oct 3, 2011 · Viewed 7.7k times · Source

Ok so, I'm getting this error when I try to use the asset pipeline. I don't understand what's causing it.

Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Photos#show

Showing .../app/views/photos/_photo_view.html.haml where line #2 raised:

jquery.autocomplete isn't precompiled

Extracted source (around line #2):

1: - content_for :scripts do
2:  = javascript_include_tag 'jquery.autocomplete'

However, this IS precompiled. I ran rake assets:precompile RAILS_ENV=production before starting the server, and in my public/assets directory I have the file: jquery-5550a245a55b28927b5552cac182e612.autocomplete.js as well as .js.gz, and it's accurately reflected in the manifest:

#manifest.yml
---
application.js: application-4277323e3f7506b71f45c71e8a3a7c8f.js
jquery.autocomplete.js: jquery-5550a245a55b28927b5552cac182e612.autocomplete.js
jquery.cycle.all.min.js: jquery-183ef696b43944deaee5778d3094dbdd.cycle.all.min.js
jquery.fancybox.js: jquery-e52e44b2b4fb349bade9beb91461a810.fancybox.js
jquery.plupload.queue.js: jquery-f2e7f6ad7d2e5ca50235ed21f8d573cc.plupload.queue.js
jquery.tools.js: jquery-c53e304240fa56767fe0f2a00cb4bceb.tools.js
plupload.full.js: plupload-5dd26ee3fff6b627c19f196e9d1429dd.full.js
application.css: application-ce5217e1714cbc4e9c3ff6c5dfc9b221.css
fancybox.css: fancybox-9ee9c36f391086e4b0629b7df4042390.css
jquery.plupload.queue.css: jquery-661fbf3f503aa32ff11c004838c0820b.plupload.queue.css
jquery.js: jquery-4d23f0cfea862f56deb04f0a8ab1fcee.js
jquery.min.js: jquery-8a50feed8d29566738ad005e19fe1c2d.min.js

The javascript file in question is not loaded in my application.js file because I only need it on one view and don't use it anywhere else in the app. To account for that (and to fix sprockets trying to compile sass partials) I configured my precompile regexp like so:

#environments/production.rb
config.assets.precompile = [/^[a-zA-Z]*\..*/]

(The above regexp precompiles any file that starts with a letter character, and ignores files starting with a non-letter character like an underscore).

Does anyone have any insight into what's causing this and how it can be fixed? The asset pipeline is making me pull my hair out!

UPDATE

just found out that Rails.configuration.assets.digests is returning nil in production. maybe the problem is there, for some reason sprockets is not finding the manifest.yml.

Im probably mistaken but seems like sprockets is not using the assets_host in config when looking for the manifest.yml.

https://github.com/rails/rails/blob/3-2-stable/actionpack/lib/sprockets/railtie.rb#L38

Answer

guzart picture guzart · Oct 15, 2011

Add the .js to

javascript_include_tag 'jquery.autocomplete.js'

Seems like there is an missing functionality. When the filename has a period '.' in the name, the .js extension will not get added when looking into the digest.

I did some debugging to Sprockets::Helpers::RailsHelper and it seems like digest_for methods gets the logical path without the .js.