Skip to content

Add more context to Sprockets::FileNotFound error messages #252

Closed
@carols10cents

Description

@carols10cents

Sort of related to #251. If the error messages I had gotten had included more information, perhaps it wouldn't matter that the documentation hadn't helped me.

This is with a brand new rails 4.2.5.1 app and sprockets 3.5.2.

The relevant part of that issue to this issue is that I had a file in app/assets/other_javascripts/f.js (a sibling directory to app/assets/javascripts, not a subdirectory) and I tried to require it in app/assets/javascripts/application.js by adding require ../other_javascripts/f. () When I run rake assets:precompile in this state, I get this error message:

Sprockets::FileNotFound: couldn't find file '../other_javascripts/f' under '/Users/carolnichols/Ruby/sprockets-test-app/app/assets/javascripts' with type 'application/javascript'

Now, I know app/assets/javascripts isn't the only place sprockets is looking, since the comment at the top of application.js says I can also put js in lib/assets/javascripts and vendor/assets/javascripts and reference them directly here.

I also happen to know that if I instead use require f, sprockets DOES find app/assets/other_javascripts/f.js (https://github.com/carols10cents/sprockets-test-app/commit/cb1315e645e5f2118776caf62b6667f7cbe323b5), so it's clearly looking more places.

It'd be great if the error message for Sprockets::FileNotFound showed me all the paths sprockets was looking for assets, and showed me how it was resolving the paths, so that I could understand and correct the path I'm putting into application.js.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions