TypeError: no implicit conversion of nil into String
SimonVillage opened this issue · comments
After update to 1.10.0 we got the following error
TypeError: no implicit conversion of nil into String
We have a css and include in the email template with this <%= render 'mail_header' %>
Email header contains
css:
body {
margin: 0;
padding: 0;
}
Could you provide more info?
- Did you upgrade premailer as well?
- Which premailer-rails version were you using before?
- Can you provide a backtrace?
Thanks.
I've also observed this; could only reproduce in production (on Heroku). Backtrace below.
To fix this issue, I downgraded / locked premailer-rails
as follows:
diff --git a/Gemfile b/Gemfile
index c68bd40d3..41155536a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -185,7 +185,7 @@ gem 'phonelib'
gem 'poltergeist', require: false, group: :test
# Stylesheet inlining for email
-gem 'premailer-rails'
+gem 'premailer-rails', '1.9.7' # Broken after - https://github.com/fphilipe/premailer-rails/issues/207
# Progress Bar for slow rake tasks
gem 'ruby-progressbar'
diff --git a/Gemfile.lock b/Gemfile.lock
index 19cfbc9a2..8506fbb57 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -362,7 +362,7 @@ GEM
addressable
css_parser (>= 1.6.0)
htmlentities (>= 4.0.0)
- premailer-rails (1.10.0)
+ premailer-rails (1.9.7)
actionmailer (>= 3, < 6)
premailer (~> 1.7, >= 1.7.9)
pry (0.11.3)
@@ -647,7 +647,7 @@ DEPENDENCIES
pg
phonelib
poltergeist
- premailer-rails
+ premailer-rails (= 1.9.7)
pry-byebug
pry-rails
rabl
Here are some related gems / versions we also use, in case relevant:
# Gemfile.lock
...
actionmailer (5.0.6)
actionpack (= 5.0.6)
actionview (= 5.0.6)
activejob (= 5.0.6)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
...
activejob (5.0.6)
activesupport (= 5.0.6)
globalid (>= 0.3.6)
...
mail (2.7.0)
mini_mime (>= 0.1.1)
...
mime-types (2.99.3)
mini_mime (1.0.0)
...
mjml-rails (2.4.3)
...
premailer (1.11.1)
addressable
css_parser (>= 1.6.0)
htmlentities (>= 4.0.0)
premailer-rails (1.9.7)
actionmailer (>= 3, < 6)
premailer (~> 1.7, >= 1.7.9)
...
Backtrace:
Rendered layouts/emails/_social_footer.mjml (0.0ms)
Rendered payment_mailer/request_payment.mjml.erb within layouts/emails/mjml_default (1.7ms)
TypeError: no implicit conversion of nil into String
from /app/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:164:in `join'
from /app/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:164:in `block in find_sources'
from /app/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:163:in `each'
from /app/vendor/bundle/ruby/2.4.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:163:in `find_sources'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `each'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `first'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `load'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:47:in `block in load_css'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:46:in `each'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:46:in `load_css'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:38:in `load_css_with_cache'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:18:in `css_for_url'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:13:in `block in css_for_doc'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:13:in `map'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:13:in `css_for_doc'
from /app/vendor/bundle/ruby/2.4.0/gems/premailer-rails-1.10.0/lib/premailer/rails/customized_premailer.rb:14:in `initialize'
... 7 levels...
from /app/vendor/bundle/ruby/2.4.0/gems/mail-2.7.0/lib/mail/mail.rb:235:in `block in inform_interceptors'
from /app/vendor/bundle/ruby/2.4.0/gems/mail-2.7.0/lib/mail/mail.rb:234:in `each'
from /app/vendor/bundle/ruby/2.4.0/gems/mail-2.7.0/lib/mail/mail.rb:234:in `inform_interceptors'
from /app/vendor/bundle/ruby/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:248:in `inform_interceptors'
from /app/vendor/bundle/ruby/2.4.0/gems/mail-2.7.0/lib/mail/message.rb:258:in `deliver'
from /app/vendor/bundle/ruby/2.4.0/gems/actionmailer-5.0.6/lib/action_mailer/message_delivery.rb:96:in `block in deliver_now'
from /app/vendor/bundle/ruby/2.4.0/gems/actionmailer-5.0.6/lib/action_mailer/rescuable.rb:15:in `handle_exceptions'
from /app/vendor/bundle/ruby/2.4.0/gems/actionmailer-5.0.6/lib/action_mailer/message_delivery.rb:95:in `deliver_now'
from (irb):4
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/console.rb:65:in `start'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/console_helper.rb:9:in `start'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:78:in `console'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /app/vendor/bundle/ruby/2.4.0/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from /app/bin/rails:15:in `require'
from /app/bin/rails:15:in `<main>'
I too am having this issue since upgrading to 1.10.0
here is my backtrace
Exception
no implicit conversion of nil into String
Backtrace
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:164:in `join'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:164:in `block in find_sources'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:163:in `each'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/sprockets-3.7.1/lib/sprockets/manifest.rb:163:in `find_sources'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `each'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `first'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_loaders/asset_pipeline_loader.rb:11:in `load'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:47:in `block in load_css'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:46:in `each'
/opt/rubies/ruby-2.3.0/lib/ruby/gems/2.3.0/gems/premailer-rails-1.10.0/lib/premailer/rails/css_helper.rb:46:in `load_css'
Same! Here's the commit that I think did it: WikiEducationFoundation/WikiEduDashboard@cbec54c
Version bumps of premailer (1.11.0 -> 1.11.1) and premailer-rails (1.9.7 -> 1.10.0)
Rolling back only premailer-rails, while keeping the latest version of premailer (1.11.1) fixed it for me.
I can confirm, that latest version premailer-rails (1.10.0)
was causing
TypeError: no implicit conversion of nil into String
error.
As temp solution, as olliebennett mentioned - lock gem to older version.
gem 'premailer-rails', '1.9.7'
If anyone is able to bisect the changes between 1.9.7
and 1.10.0
, to identify the exact commit which introduced the problem, I suspect it would help with preparing a fix.
Thanks everyone for reporting. I'll have a closer look.
@kirs, @rafaelfranca, any idea what might be causing this? It seems related to the introduction of the the asset manifest in #201.
That assets is not in the precompile list so it can't be found in the manifest. This exception is fixed on the 3.x branch of sprockets but even with the sprockets release people will need to add the assets to the precompile list
@rafaelfranca thanks for the insight!
@TAiS46, @joshterry55, @ragesoss, @epicatization, @olliebennett, @chesles, does adding the CSS file to the sprockets manifest fix the problem, as @rafaelfranca suggested?
In my case the file causing this appears to be a 3rd party font stylesheet link, which if I understand correctly can't be included in the manifest using =require
directives:
<%= stylesheet_link_tag 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,700' %>
Using a local copy of the file and referencing it using =require
in my email.css file does fix the problem for me, though. Thanks for your help!
Sorry about the issue. We've been rescuing similar exceptions from Sprockets, but not TypeError
.
#209 should fix the bug.
Version 1.10.1 was released. Thanks everyone!