-
Notifications
You must be signed in to change notification settings - Fork 789
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
Unexpected require path, given the current documentation #251
Comments
I think this is because
To the error message. |
You can add a load path like this http://stackoverflow.com/questions/14735635/add-folder-to-asset-pipeline-path |
@schneems it is in the load path -- that's why a straight Enumerating the paths we searched would certainly clarify the behaviour, but might be quite the flood of information: in an average setup, there are a lot of directories on the load path. One thought: what if we enumerated the logical path to every known asset with a matching basename? (only in So even if you tried to include |
Hi @schneems !
If
I totally agree :) #252 |
That would also be incredible :) |
This might just be a documentation issue, but this left me pretty confused. So here's a dramatic re-enactment of what happened:
rake assets:precompile
and it completed successfully, and had the contents of a, b, and c in the compiled application.js. So far so good.app/assets/javascripts/d/e.js
and added this to application.js (https://github.com/carols10cents/sprockets-test-app/commit/8abff570b61a9e84e245efb66e1f90f7910c276e):rake assets:precompile
and it again completed successfully, and the contents of e.js were in the compiled application.js. Ok, cool.app/assets/other_javascripts/f.js
(note that the other_javascripts is a sibling directory of app/assets/javascripts, not a subdirectory) and I referenced it with a relative path in application.js:require other_javascripts/f
, which gives me a slightly different error:require f
, and... SURPRISE! That works!! (https://github.com/carols10cents/sprockets-test-app/commit/cb1315e645e5f2118776caf62b6667f7cbe323b5) This is really unexpected, and the docs definitely didn't lead me there, I was just guessing.require d/e
to justrequire e
and that errored as I would have originally expected, but afterother_javascripts/f
could be referenced just withf
, I kind of expected it to work. The error I get with that is:require ./../other_javascripts/f
, since it says "Relative paths begin with ./ and reference files relative to the location of the current file.". Alas:One more thing: I lied. I wasn't creating a brand new app. I'm trying to upgrade an existing app from using sprockets 2.12 to using sprockets 3.5.
require ../other_javascripts/f
works totally fine with sprockets 2.12.4 (https://github.com/carols10cents/sprockets-test-app/commit/cf4bd8a68b722d768fd4094463a9e7b112afd8ca) (incidentally,require f
works with sprockets 2.12.4 as well but our existing code was the other way) and I didn't see anything in https://github.com/rails/sprockets/blob/3.x/UPGRADING.md about paths like '../other_javascripts/f' needing to be updated :-/If this is indeed deemed just a documentation issue, I can try adding the docs that would have helped me-- but I do want to make sure this isn't a bug first :)
Thank you!! <3 <3 <3
The text was updated successfully, but these errors were encountered: