Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Conversation

arlm
Copy link
Contributor

@arlm arlm commented Feb 22, 2013

This issue happened on heroku and my local repository. It happened because my assets were on lib/assets and not public/assets

Fixes issue #101

@micha-f
Copy link

micha-f commented Feb 26, 2013

This patch doesn't work with our coffeescript codebase: It causes requirejs to try and work on the .coffee source files instead of the compiled js files.

@arlm
Copy link
Contributor Author

arlm commented Feb 26, 2013

@micha-f Please send me a sample. I used the default Rails 3.x asset manager to resolve the file address on the filesystem in order to load it, maybe the .coffee file should be treated differently or it is not registered as such on the default asset chain.

@micha-f
Copy link

micha-f commented Feb 26, 2013

@pboling
Copy link

pboling commented Mar 2, 2013

👎 I am experiencing this hexdigest error now.

EDIT: @micha-f @arlm, it is true. This patch causes coffe script to be ignored, which results ILLEGAL TOKEN errors because coffe script is not javascript. :(

@jwhitley
Copy link
Owner

jwhitley commented Mar 9, 2013

So your assets aren't in public/assets. Ok. Was this an explicit change on your part, or something Heroku is doing to you?

What does Rails.public_path say in rails console for you?

@arlm
Copy link
Contributor Author

arlm commented Mar 9, 2013

@micha-f, I cloned your repo and run the commands. I used requirejs-rails from my patched repo and I did not get errors:

$ rake assets:precompile
/Users/.../.rvm/rubies/ruby-1.9.3-p385/bin/ruby /Users/.../.rvm/gems/ruby-1.9.3-p385@global/bin/rake requirejs:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
/Users/.../.rvm/rubies/ruby-1.9.3-p385/bin/ruby /Users/.../.rvm/gems/ruby-1.9.3-p385@global/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets

$ ls app/assets/javascripts/
application.js  main.coffee     main.coffee.gz  

$ ls public/assets/
application-037cd77f2ee9f14dd5b7f9a4b4a24306.js      jquery.min-6c267bfd2b3f36e6edccb2e584934c1c.map      rails-a3386665c05a2d82f711a4aaa72d247c.png
application-037cd77f2ee9f14dd5b7f9a4b4a24306.js.gz   jquery.min.map                                       rails.png
application-1b13569e9620782f423d4cd3ce931750.css     main-408d0766e9f15e785b24fc7234ed994e.js             require-cbfc3f690e2109e37e09aefd8fe40332.js
application-1b13569e9620782f423d4cd3ce931750.css.gz  main-408d0766e9f15e785b24fc7234ed994e.js.gz          require-cbfc3f690e2109e37e09aefd8fe40332.js.gz
application.css                                      main.coffee-307dda5f457b28647ddfb9e798c88db6.gz      require.js
application.css.gz                                   main.coffee.gz                                       require.js.gz
application.js                                       main.js                                              rjs_manifest.yml
application.js.gz                                    manifest.yml                                        

I don't use coffee scripts, but it seems that the issue has nothing to do with requirejs-rails but with the way you are using it or a rails problem. Your code didn't even call requirejs

@micha-f
Copy link

micha-f commented Mar 9, 2013

@arlm, there is a module 'main' in requirejs.yml which it builds.

There are no errors when running assets:precompile. However, it creates coffee.gz files (useless + shouldn't touch the app/assets dir) and the coffee script is not actually compiled:

$ cat public/assets/main-408d0766e9f15e785b24fc7234ed994e.js  
define ->
  alert "something"

@jwhitley
Copy link
Owner

This PR has multiple problems as it stands, so I'm going to reject it as a whole (keeping parts) and close this issue. That said, I very much appreciate the request, and have some feedback for future reports/PRs below. The digest warning is a good idea, thanks. I've cherry-picked that and upgraded it to be an error. IMO this deserves error treatment, since it means the build couldn't find an expected/required asset. At that point, all bets are off and the build should be considered corrupt.

I'll note that the proposed change to find the asset pathname isn't correct as others with CoffeeScript problems have found out the hard way. find_asset here does a full asset path search, but the path to digest should be the asset file located in the build target directory.

Last but not least, this issue has incomplete repro steps and/or tests. A potential cause (assets in lib/assets) is mentioned but not how or why this came to be. I'm looking for things like "I set config.foo = 'blah' in environment.rb, which puts my built assets in lib/assets" and/or a failing test that illustrates the issue and validates a fix. Without this, it's hard for me to determine what was intended to be fixed, whether it was truly fixed, and what the regression risks might be.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants