Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
carols10cents opened this issue Feb 24, 2016 · 3 comments
Closed

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

carols10cents opened this issue Feb 24, 2016 · 3 comments

Comments

@carols10cents
Copy link

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.

5minpause pushed a commit to 5minpause/sprockets that referenced this issue Jun 16, 2016
When `resolve!` raises an error, it would not display the paths that
were used to look up the assets. If we raise this error we can be even
more helpful and display the `config[:path]` as well. This makes it
easier for users to debug their asset paths.

References rails#252
5minpause pushed a commit to 5minpause/sprockets that referenced this issue Jun 16, 2016
When `resolve!` raises an error, it would not display the paths that
were used to look up the assets. If we raise this error we can be even
more helpful and display the `config[:path]` as well. This makes it
easier for users to debug their asset paths.

References rails#252
@5minpause
Copy link
Contributor

Hi @schneems I created a pull request, that displays the load paths together with the regular error message. Perhaps this is helpful? Any feedback is appreciated.
I opened the PR to the branch 3.x. Does this make sense? Or is development only done in master?

schneems pushed a commit that referenced this issue Jul 21, 2016
When `resolve!` raises an error, it would not display the paths that
were used to look up the assets. If we raise this error we can be even
more helpful and display the `config[:path]` as well. This makes it
easier for users to debug their asset paths.

References #252
@schneems
Copy link
Member

Ugh, I only merged that behavior into 3.x and not into master. There is a branch I need to get green on tests first #322.

@schneems
Copy link
Member

This was fixed in #322

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants