错误:找不到要导入的文件或无法读取:引导电子邮件
Posted
技术标签:
【中文标题】错误:找不到要导入的文件或无法读取:引导电子邮件【英文标题】:Error: File to import not found or unreadable: bootstrap-email 【发布时间】:2021-12-08 20:32:40 【问题描述】:在将 rails 从 5.2 升级到 6.1.0 并将 ruby 从 2.5 升级到 3.0.2 后,我遇到了这个错误。它适用于 ruby 2.7 和 rails 6.0 版本。
它在 bootstrap-email 版本 0.3.0 上运行良好,但在使用 ruby 3.0.2 升级 1.0.1 后会中断。
我也在 GitHub 上提出了同样的问题,这里是链接 https://github.com/bootstrap-email/bootstrap-email/discussions/143
mailer/changed_password_alert
should verify reset password email content (FAILED - 1)
Failures:
1) mailer/changed_password_alert should verify reset password email content
Failure/Error: @import 'bootstrap-email';
ActionView::Template::Error:
Error: File to import not found or unreadable: bootstrap-email.
on line 6:1 of app/assets/stylesheets/mailer/index.scss
>> @import 'bootstrap-email';
^
# ./app/assets/stylesheets/mailer/index.scss:6
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sassc-2.4.0/lib/sassc/engine.rb:50:in `render'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:40:in `block in call'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/utils.rb:138:in `module_include'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sassc-rails-2.1.2/lib/sassc/rails/template.rb:39:in `call'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:33:in `call'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/bundle.rb:27:in `call'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:84:in `call_processor'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:66:in `block in call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `reverse_each'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/processor_utils.rb:65:in `call_processors'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:182:in `load_from_unloaded'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:59:in `block in load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:337:in `fetch_asset_from_dependency_cache'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/loader.rb:43:in `load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/cached_environment.rb:44:in `load'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/base.rb:81:in `find_asset'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-4.0.2/lib/sprockets/base.rb:119:in `[]'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:358:in `find_asset'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:337:in `digest_path'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:326:in `asset_path'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:103:in `block in resolve_asset_path'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:243:in `block in resolve_asset'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:242:in `each'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:242:in `detect'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:242:in `resolve_asset'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:102:in `resolve_asset_path'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:80:in `compute_asset_path'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:186:in `block in stylesheet_link_tag'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:184:in `map'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/sprockets-rails-3.2.2/lib/sprockets/rails/helper.rb:184:in `stylesheet_link_tag'
# ./app/views/mailer/changed_password_alert.html.erb:1:in `_app_views_mailer_changed_password_alert_html_erb__553806408343225745_26440'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/haml-5.2.2/lib/haml/helpers/action_view_mods.rb:15:in `render'
# ./spec/views/mailer/changed_password_alert.html.erb_spec.rb:11:in `block (2 levels) in <top (required)>'
# ./spec/rails_helper.rb:80:in `block (3 levels) in <top (required)>'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/database_cleaner-core-2.0.1/lib/database_cleaner/strategy.rb:30:in `cleaning'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:34:in `block (2 levels) in cleaning'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/database_cleaner-core-2.0.1/lib/database_cleaner/cleaners.rb:35:in `cleaning'
# ./spec/rails_helper.rb:79:in `block (2 levels) in <top (required)>'
# /Users/vishal_pandey/.rvm/gems/ruby-3.0.2/gems/webmock-3.14.0/lib/webmock/rspec.rb:37:in `block (2 levels) in <top (required)>'
# ------------------
# --- Caused by: ---
# SassC::SyntaxError:
# Error: File to import not found or unreadable: bootstrap-email.
# on line 6:1 of app/assets/stylesheets/mailer/index.scss
# >> @import 'bootstrap-email';
#
# ^
# ./app/assets/stylesheets/mailer/index.scss:6
Top 1 slowest examples (0.19216 seconds, 20.0% of total time):
mailer/changed_password_alert should verify reset password email content
0.19216 seconds ./spec/views/mailer/changed_password_alert.html.erb_spec.rb:6
Finished in 0.9595 seconds (files took 22.39 seconds to load)
1 example, 1 failure
系统配置
Rails version: 6.1.0
Ruby version: 3.0.2
bootstrap-email version: 1.0.1
【问题讨论】:
【参考方案1】:尝试安装 premailer-rails gem。 bootstrap-email 需要它。
https://github.com/fphilipe/premailer-rails
【讨论】:
以上是关于错误:找不到要导入的文件或无法读取:引导电子邮件的主要内容,如果未能解决你的问题,请参考以下文章
错误:找不到要导入的文件或无法读取:~bootstrap/scss/bootstrap
webpack 错误:找不到要导入的文件或无法读取:波旁威士忌,如何解决?
Rails 3 应用程序中的 Sass 导入错误 - “找不到或无法读取要导入的文件:指南针”
找不到或无法读取要导入的 Angular CLI SCSS 文件
如何解决(插件 postcss)错误:找不到或无法读取要导入的文件:smui-theme. Material UI Svelte 项目