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

Causes unwanted changes in hexdigest for other post_processors #15

Closed
JakeTheSnake3p0 opened this issue May 13, 2014 · 10 comments
Closed

Comments

@JakeTheSnake3p0
Copy link

Full issue here. Essentially I have to comment out this gem to get the other to work. I can't comment really as to why, but this is where I'm at.

The sprockets-webp gem creates a .webp file from that assets. When sprockets-image_compressor is commented out in the Gemfile, all asset digests match. When I activate this gem, the .webp files have a different digest in the filename.

@botandrose
Copy link
Owner

Hmm, interesting. I'm not sure what's causing this, but it sounds like a bug. If you can create a repo that reproduces this issue in a reduced way, I'll take a look.

@JakeTheSnake3p0
Copy link
Author

I'll be able to in about 4-5 hours.

@JakeTheSnake3p0
Copy link
Author

I created a new rails application with both gems installed and it seems to be working...there must be something wonky with either my config or some strange setting as I can't seem to reproduce it outside of this specific application. I've even tried whittling down my Gemfile in my current app just to the bare bones and I'm still getting this issue. I've tried symlinking my app/assets directory to working rails apps just to make sure there's nothing wrong with the files. Stranger than fiction man.

@botandrose
Copy link
Owner

Weird! It does suggest, at least, that if you can discover the essential difference between the barebones app that doesn't exhibit the issue, and the fullblown that does, you'll find the crux of the issue itself. Let me know what you discover!

@JakeTheSnake3p0
Copy link
Author

OK, I think I may have stumbled upon something. I can't say why, but the order in which I declare the gems in my Gemfile affects the outcome.

This causes the problem:

gem 'sprockets-webp' if RUBY_PLATFORM !~ /mingw/
gem 'sprockets-image_compressor'

This works:

gem 'sprockets-image_compressor'
gem 'sprockets-webp' if RUBY_PLATFORM !~ /mingw/

FWIW, I'm testing on a Ubuntu VM and I have to restart every time I make these changes because of NFS updates/deletions.

So to summarize:

  1. Change Gemfile such that sprockets-image_compressor comes after sprockets-webp
  2. bundle update && bundle clean --force
  3. Make sure the public/assets directory is removed (because of VM I have to restart machine at this point)
  4. RAILS_ENV=production bundle exec rake tmp:cache:clear assets:precompile

--- The file hashes don't match

5...) Repeat above process but put sprockets-image_compressor before sprockets-webp

--- The file hashes match

@JakeTheSnake3p0
Copy link
Author

Small update, maybe not related. I'm now getting an encoding error even though it's a jpg and shouldn't be processed.

Encoding::InvalidByteSequenceError: /home/jake/ror/dev.website/app/assets/images/emails/email-footer_bg.jpg is not valid UTF-8
  (in /home/jake/ror/dev.website/app/assets/images/emails/email-footer_bg.jpg)
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/tilt-1.4.1/lib/tilt/template.rb:75:in `initialize'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/context.rb:196:in `new'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/context.rb:196:in `block in evaluate'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:12:in `initialize'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger'
/home/jake/.rvm/gems/ruby-2.1.0@website/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define'
/home/jake/.rvm/gems/ruby-2.1.0@global/bin/ruby_executable_hooks:15:in `eval'
/home/jake/.rvm/gems/ruby-2.1.0@global/bin/ruby_executable_hooks:15:in `<main>'

@botandrose
Copy link
Owner

Good work, so it seems like the order of sprockets processor registration matters. Thinking about it, it makes sense that the compressor processor should be registered before the webp processor. After all, we want the pipeline to be original -> compressor -> webp, not original -> webp -> compressor. I wonder if this is something we can (or should) fix in code, or if perhaps documentation in the README is a better way to go. What do you think?

The error you posted above seems unrelated to me. Can you create a new issue for that, and attach the offending image to it?

@JakeTheSnake3p0
Copy link
Author

It's probably best to put it in the README. Since the cache-buster key of the compiled asset is based on the file structure/environment, it wouldn't make sense to modify the key just for the sake of consistency with what another gem creates.

The error I posted above still results from the combination of the two gems. If I comment out either one, the error doesn't crop up; only when both gems are present does the error show up. I'll create a new issue for this though.

@botandrose
Copy link
Owner

I'm going to reopen this, pending an addition to the README.

@JakeTheSnake3p0
Copy link
Author

Here's the next issue: #16

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

2 participants