Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

AssetIncludeTag ensures that files are in the wrong directory

#6015

javascript_include_tag and stylesheet_link_tag check that the included paths actually exist as files. Under certain circumstances this check is performed in the wrong directory and an error is raised even though all files exist.

The circumstances that expose this issue are:

  1. The included paths are named paths like 'script.js' (instead of :all)
  2. The asset tag helper is called with the :cache => true option
  3. config.perform_caching is set to false
  4. The application is running with a relative URL root ("sub-URI deployment")

The error that the paths correctly prefixed by the relative URL root are also used to check the files' existence. Since a path prefixed that way is a virtual path that does not exist in the local file system, that check fails.

My proposed fix is that paths used to check file existence should not be prefixed by the relative URL root. I will upload a patch with tests for this.

Steps to reproduce:

  1. Configure a Passenger application with RackBaseURI /sub-folder
  2. In the active application environment, set config.perform_caching = false
  3. In any view link to an existing javascript file: <%= javascript_include_tag 'script.js', :cache => true %><br/>
  4. Open that view in the browser
  5. You will see the follow error:

No such file or directory - Asset file not found at '/home/username/rails-project/public/sub-folder/javascripts/script.js'

Reported by Henning · November 19th, 2010 @ 05:15 PM

State: resolved
Milestone: none
Assigned to: nobody
Importance: none