ndbroadbent / turbo-sprockets-rails3

Speeds up your Rails 3 assets:precompile by only recompiling changed files, and only compiling once to generate all assets
MIT License
974 stars 76 forks source link

Looks like doesn't play well with `premailer-rails3' #28

Open linjunpop opened 12 years ago

linjunpop commented 12 years ago

I dont know if it's a premailer-rails3's issue or this gem's.

So I put details on fphilipe/permailer-rails3#53

https://github.com/fphilipe/premailer-rails3/issues/53

ndbroadbent commented 12 years ago

Hi, thanks for opening an issue!

I think I have might have been able to fix this, if I'm right that it's an issue with my modifications to the asset cache.

Please update to 0.2.12 and let me know if the problem is solved. Cheers!

linjunpop commented 12 years ago

Hi @ndbroadbent

I still get same issue after I update to 0.2.12

Here's the Gemfile.lock

GIT
  remote: git://github.com/anjlab/bootstrap-rails.git
  revision: f48c60c989d1dadb057490e83285c44e613fbc08
  specs:
    anjlab-bootstrap-rails (2.1.1.1)
      railties (>= 3.0)
      sass (>= 3.2)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.8)
      actionpack (= 3.2.8)
      mail (~> 2.4.4)
    actionpack (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.4)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.3)
    activemodel (3.2.8)
      activesupport (= 3.2.8)
      builder (~> 3.0.0)
    activerecord (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.8)
      activemodel (= 3.2.8)
      activesupport (= 3.2.8)
    activesupport (3.2.8)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    addressable (2.3.2)
    airbrake (3.1.6)
      builder
      girl_friday
    arel (3.0.2)
    awesome_print (1.1.0)
    barby (0.5.0)
    bcrypt-ruby (3.0.1)
    bootstrap-kaminari-views (0.0.2)
      kaminari (>= 0.13)
      rails (>= 3.1)
    builder (3.0.4)
    capistrano (2.13.5)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    capistrano-ext (1.2.1)
      capistrano (>= 1.0.0)
    capistrano-gitflow (1.4.3)
      capistrano
      stringex
    capistrano_colors (0.5.5)
    carrierwave (0.7.0)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
    celluloid (0.12.3)
      facter (>= 1.6.12)
      timers (>= 1.0.0)
    chunky_png (1.2.6)
    coderay (1.0.8)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.4.0)
    compass (0.12.2)
      chunky_png (~> 1.2)
      fssm (>= 0.2.7)
      sass (~> 3.1)
    compass-rails (1.0.3)
      compass (>= 0.12.2, < 0.14)
    connection_pool (0.9.2)
    css_parser (1.2.6)
      addressable
      rdoc
    daemons (1.1.9)
    devise (2.1.2)
      bcrypt-ruby (~> 3.0)
      orm_adapter (~> 0.1)
      railties (~> 3.1)
      warden (~> 1.2.1)
    devise-async (0.3.1)
      devise (>= 1.1)
    diff-lcs (1.1.3)
    em-websocket (0.3.8)
      addressable (>= 2.1.1)
      eventmachine (>= 0.12.9)
    erubis (2.7.0)
    eventmachine (1.0.0)
    excon (0.16.7)
    execjs (1.4.0)
      multi_json (~> 1.0)
    facter (1.6.13)
    factory_girl (4.1.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.1.0)
      factory_girl (~> 4.1.0)
      railties (>= 3.0.0)
    fog (1.6.0)
      builder
      excon (~> 0.14)
      formatador (~> 0.2.0)
      mime-types
      multi_json (~> 1.0)
      net-scp (~> 1.0.4)
      net-ssh (>= 2.1.3)
      nokogiri (~> 1.5.0)
      ruby-hmac
    foreigner (1.2.1)
      activerecord (>= 3.0.0)
    formatador (0.2.4)
    fssm (0.2.9)
    girl_friday (0.10.0)
      connection_pool (~> 0.9.0)
    guard (1.5.1)
      listen (>= 0.4.2)
      lumberjack (>= 1.0.2)
      pry (>= 0.9.10)
      thor (>= 0.14.6)
    guard-livereload (1.1.0)
      em-websocket (>= 0.2.0)
      guard (>= 1.5.0)
      multi_json (~> 1.0)
    guard-rspec (2.1.0)
      guard (>= 1.1)
      rspec (~> 2.11)
    haml (3.1.7)
    highline (1.6.15)
    hike (1.2.1)
    htmlentities (4.3.1)
    i18n (0.6.1)
    journey (1.0.4)
    jquery-rails (2.1.3)
      railties (>= 3.1.0, < 5.0)
      thor (~> 0.14)
    jquery_datepicker (0.4)
    json (1.7.5)
    kaminari (0.14.1)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kgio (2.7.4)
    listen (0.5.3)
    lumberjack (1.0.2)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mailcatcher (0.5.10)
      activesupport (~> 3.0)
      eventmachine (~> 1.0.0)
      haml (~> 3.1)
      mail (~> 2.3)
      sinatra (~> 1.2)
      skinny (~> 0.2.3)
      sqlite3 (~> 1.3)
      thin (~> 1.5.0)
    method_source (0.8.1)
    mime-types (1.19)
    mini_magick (3.4)
      subexec (~> 0.2.1)
    multi_json (1.3.6)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.5.2)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    nokogiri (1.5.5)
    orm_adapter (0.4.0)
    pg (0.14.1)
    polyamorous (0.5.0)
      activerecord (~> 3.0)
    polyglot (0.3.3)
    premailer (1.7.3)
      css_parser (>= 1.1.9)
      htmlentities (>= 4.0.0)
    premailer-rails3 (1.3.1)
      premailer (~> 1.7)
      rails (~> 3)
    pry (0.9.10)
      coderay (~> 1.0.5)
      method_source (~> 0.8)
      slop (~> 3.3.1)
    pry-rails (0.2.2)
      pry (>= 0.9.10)
    puma (1.6.3)
      rack (~> 1.2)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-protection (1.2.0)
      rack
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (3.2.8)
      actionmailer (= 3.2.8)
      actionpack (= 3.2.8)
      activerecord (= 3.2.8)
      activeresource (= 3.2.8)
      activesupport (= 3.2.8)
      bundler (~> 1.0)
      railties (= 3.2.8)
    railties (3.2.8)
      actionpack (= 3.2.8)
      activesupport (= 3.2.8)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    raindrops (0.10.0)
    rake (0.9.2.2)
    ransack (0.7.0)
      actionpack (~> 3.0)
      activerecord (~> 3.0)
      polyamorous (~> 0.5.0)
    rb-readline (0.4.2)
    rdoc (3.12)
      json (~> 1.4)
    redis (3.0.2)
    redis-namespace (1.2.1)
      redis (~> 3.0.0)
    rmagick (2.13.1)
    rspec (2.11.0)
      rspec-core (~> 2.11.0)
      rspec-expectations (~> 2.11.0)
      rspec-mocks (~> 2.11.0)
    rspec-core (2.11.1)
    rspec-expectations (2.11.3)
      diff-lcs (~> 1.1.3)
    rspec-mocks (2.11.3)
    rspec-rails (2.11.4)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      railties (>= 3.0)
      rspec (~> 2.11.0)
    ruby-growl (3.0)
    ruby-hmac (0.4.0)
    rvm-capistrano (1.2.7)
      capistrano (>= 2.0.0)
    sass (3.2.1)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    seed-fu (2.2.0)
      activerecord (~> 3.1)
      activesupport (~> 3.1)
    semacode-ruby19 (0.7.4)
      rake (>= 0.7.0)
    shoulda-matchers (1.4.1)
      activesupport (>= 3.0.0)
    sidekiq (2.5.1)
      celluloid (~> 0.12.0)
      compass
      connection_pool (~> 0.9.2)
      multi_json (~> 1)
      redis (~> 3)
      redis-namespace
      sass
      sprockets-sass
    simple_form (2.0.4)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    sinatra (1.3.3)
      rack (~> 1.3, >= 1.3.6)
      rack-protection (~> 1.2)
      tilt (~> 1.3, >= 1.3.3)
    skinny (0.2.3)
      eventmachine (~> 1.0.0)
      thin (~> 1.5.0)
    slim (1.3.3)
      temple (~> 0.5.5)
      tilt (~> 1.3.3)
    slim-rails (1.0.3)
      actionpack (~> 3.0)
      activesupport (~> 3.0)
      railties (~> 3.0)
      slim (~> 1.0)
    slop (3.3.3)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-sass (0.9.1)
      sprockets (~> 2.0)
      tilt (~> 1.1)
    sqlite3 (1.3.6)
    stringex (1.4.0)
    subexec (0.2.2)
    switch_user (0.8.0)
    temple (0.5.5)
    thin (1.5.0)
      daemons (>= 1.0.9)
      eventmachine (>= 0.12.6)
      rack (>= 1.0.0)
    thor (0.16.0)
    tilt (1.3.3)
    timers (1.0.1)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    turbo-sprockets-rails3 (0.2.12)
      railties (>= 3.1.0, < 3.2.9)
      sprockets (>= 2.0.0)
    tzinfo (0.3.34)
    uglifier (1.3.0)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)
    unicorn (4.4.0)
      kgio (~> 2.6)
      rack
      raindrops (~> 0.7)
    unicorn-rails (0.0.1)
      rack
      unicorn
    warden (1.2.1)
      rack (>= 1.0)
    wisepdf (1.2.5)

PLATFORMS
  ruby

DEPENDENCIES
  airbrake
  anjlab-bootstrap-rails!
  awesome_print
  barby
  bootstrap-kaminari-views
  capistrano
  capistrano-ext
  capistrano-gitflow
  capistrano_colors
  carrierwave
  coffee-rails
  compass-rails
  devise
  devise-async
  factory_girl_rails
  fog
  foreigner
  guard-livereload
  guard-rspec
  jquery-rails
  jquery_datepicker
  kaminari
  mailcatcher
  mini_magick
  net-ssh (= 2.5.2)
  nokogiri
  pg
  premailer-rails3
  pry-rails
  puma
  rails (= 3.2.8)
  ransack
  rb-readline (~> 0.4.2)
  rmagick
  rspec-rails (~> 2.0)
  ruby-growl (~> 3.0)
  rvm-capistrano
  sass-rails (~> 3.2.3)
  seed-fu
  semacode-ruby19
  shoulda-matchers
  sidekiq
  simple_form
  sinatra
  slim-rails
  switch_user
  turbo-sprockets-rails3
  uglifier (>= 1.0.3)
  unicorn-rails
  wisepdf
ndbroadbent commented 12 years ago

Ok, sorry about that! I'll try to reproduce the problem and fix it very soon

ndbroadbent commented 12 years ago

@linjunpop, could you please try to add the turbo-sprockets-rails3 gem to :assets group in your Gemfile, like this:

group :assets do
  ...
  gem 'turbo-sprockets-rails3'
end

That should make the error go away in production while I work out what's causing it

ndbroadbent commented 12 years ago

Also, it would be very useful if you could please post your Gemfile, so I can see the groups that gems belong to

ndbroadbent commented 12 years ago

One more thing: Do you have compass (or compass-rails) in your :assets group? If so, the compass gem will not be loaded unless you start the rails console with RAILS_GROUPS=assets, and you will get the File to import not found or unreadable: compass. error.

After updating to 0.2.12, did you run rake assets:precompile before trying again? If not, you will still get that error, because the assets cache will not have been updated.

The issue is that Rails.application.assets.find_asset('email.css') first tries to look up the asset from the cache that was built during the last precompile. Previous versions of my gem were messing with the cache keys, but I restored the original cache keys in 0.2.12, so this problem shouldn't be happening any more.

So, please perform the following steps and let me know if the problem goes away:

Thanks!

linjunpop commented 12 years ago

Sorry I didn't realize this change:

https://github.com/ndbroadbent/turbo-sprockets-rails3/commit/a3b5000e9dbbb5dc20be975c195b42ae3abb0c01

And after I add turbo-sprockets-rails3 to :assets group, and clean all assets, and re-deploy again, it still throw same error.

And If I RAILS_ENV=production bundle exec rails console

1.9.3p194 :001 > Rails.application.assets.find_asset('email.css')
 => nil 

The Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.8'

gem 'pg'
gem 'slim-rails'
gem 'simple_form'
gem 'nokogiri'
gem 'premailer-rails3'
gem 'devise'
gem 'devise-async'
gem 'jquery-rails'
gem 'foreigner'
gem 'awesome_print'
gem 'jquery_datepicker'
gem 'seed-fu'
gem 'carrierwave'
gem 'rmagick'  # need to first sudo aptitude install libmagickcore-dev libmagickwand-dev
gem 'wisepdf'
#gem 'wkhtmltopdf-heroku' # if use heroku, include
gem 'coffee-rails'
gem 'fog'
gem "rb-readline", "~> 0.4.2"
gem 'switch_user'
gem 'kaminari'
gem 'bootstrap-kaminari-views'
gem 'semacode-ruby19'
gem 'barby'
gem 'sidekiq'
gem 'sinatra', :require => nil
gem "mini_magick"
gem 'puma'
gem 'airbrake'
gem "ransack"

group :production do
  gem 'unicorn-rails'
  # gem 'thin'   # heroku
end

group :assets do
  gem 'compass-rails'
  gem 'sass-rails',   '~> 3.2.3'
  gem 'anjlab-bootstrap-rails', :require => 'bootstrap-rails',
                                :git => 'git://github.com/anjlab/bootstrap-rails.git'
  gem 'uglifier', '>= 1.0.3'

  gem 'turbo-sprockets-rails3'
end

group :development do
  gem 'capistrano'
  gem 'capistrano-ext'
  gem 'capistrano-gitflow'
  gem 'capistrano_colors'
  gem 'rvm-capistrano'
  gem 'ruby-growl', '~>3.0'
  gem 'guard-livereload'
  gem 'guard-rspec'
  gem 'net-ssh', '=2.5.2'
  gem 'pry-rails'
  gem 'mailcatcher'
end

group :test do
  gem "shoulda-matchers"
  gem 'factory_girl_rails'
end

group :test, :development do
  gem "rspec-rails", "~> 2.0"
end

I'm wondering if this error only happens on this app.

kjf commented 11 years ago

I'm seeing a similar issue when used in conjunction with premailer.

gucki commented 11 years ago

I was just bitten by the same error... :(

maletor commented 11 years ago

This is a problem for us as well but with roadie.

maletor commented 11 years ago

We have temporarily resolved the issue by moving the sass file to plain old css and including it as <style> tags that Roadie picks up and inlines.

Mange commented 11 years ago

Does it work if you pass the CSS names to the mail method, @maletor?

class Whatever < ActionMailer::Base
  def whatever
    mail(to: 'foo@example.com', css: 'whatever_email.css')
  end
end
maletor commented 11 years ago

That's what I had tried first, through the defaults Hash.

ndbroadbent commented 11 years ago

Hey guys, @sbleon has kindly fixed the issue with premailer-rails3 and opened a pull request at https://github.com/fphilipe/premailer-rails3/pull/55.

Until that's merged, you could use his patch by replacing gem 'premailer-rails3' with this:

gem 'premailer-rails3', :github => 'singlebrook/premailer-rails3', :branch => 'precompiled_assets'
Mange commented 11 years ago

Aha, so the problem is that this gem is put in the :assets group? Does it work if it's placed outside of it?

ndbroadbent commented 11 years ago

Ah, nope, the problem was a bug in premailer-rails3, where it was trying to recompile CSS in production instead of reading the already compiled assets.

Mange commented 11 years ago

Oh, so it's probably some other unrelated problem that makes this fail with Roadie, then. Den 29 jan 2013 11:52 skrev "Nathan Broadbent" notifications@github.com:

Ah, nope, the problem was a bug in premailer-rails3, where it was trying to recompile CSS in production instead of reading the already compiled assets.

— Reply to this email directly or view it on GitHubhttps://github.com/ndbroadbent/turbo-sprockets-rails3/issues/28#issuecomment-12829429.

maletor commented 11 years ago

Hopefully it's a similar problem where the work on fphilipe/premailer-rails3#55 might be duplicated on Roadie.

sbleon commented 11 years ago

Rails should really take care of this for us. It's crazy for lots of different projects to have to consult Rails' configuration to figure out what method to call. I think that Rails.application.assets.find_asset should return the compiled asset if one exists. I'm hoping to find time to file an issue against Rails for this. I'll make sure to link it here if I get around to it.

On Tue, Jan 29, 2013 at 11:03 AM, Ellis Berner notifications@github.comwrote:

Hopefully a similar problem where the work might be duplicated there.

On Tuesday, January 29, 2013, Magnus Bergmark wrote:

Oh, so it's probably some other unrelated problem that makes this fail with Roadie, then. Den 29 jan 2013 11:52 skrev "Nathan Broadbent" <notifications@github.com<javascript:_e({}, 'cvml', 'notifications@github.com');>>:

Ah, nope, the problem was a bug in premailer-rails3, where it was trying to recompile CSS in production instead of reading the already compiled assets.

— Reply to this email directly or view it on GitHub<

https://github.com/ndbroadbent/turbo-sprockets-rails3/issues/28#issuecomment-12829429>.

— Reply to this email directly or view it on GitHub< https://github.com/ndbroadbent/turbo-sprockets-rails3/issues/28#issuecomment-12841482>.

— Reply to this email directly or view it on GitHubhttps://github.com/ndbroadbent/turbo-sprockets-rails3/issues/28#issuecomment-12841759.

maletor commented 11 years ago

https://github.com/Mange/roadie/pull/45