警告。 保存缓存时遇到错误…无法转储匿名类

当使用capistrano部署app时,在production.log中会出现错误。

Compiled signup.css (30ms) (pid 31797) Warning. Error encountered while saving cache /home/deployer/apps/example.com/releases/20140315211501/tmp/cache/sass/c76a96d592cb37dc7092a4e2f10ad8d3d22bcc8b/user_sessions.css.scssc: can't dump anonymous class # Compiled user_sessions/user_sessions.css (16ms) (pid 31797) Compiled user_sessions.css (20ms) (pid 31797) Warning. Error encountered while saving cache /home/deployer/apps/example.com/releases/20140315211501/tmp/cache/sass/a59f84087c66a48b1521281da138ce9e3ed4c217/welcome.css.scssc: can't dump anonymous class # 

这是我正在使用的Gemfile.lock。

 GIT remote: git://github.com/tomazzlender/letter_opener.git revision: 29b17fefe87b8fdc7ead987dbfabe355b59ff684 specs: letter_opener (0.0.2) launchy GIT remote: git://github.com/tomazzlender/premailer.git revision: 88af5e6f60ac78ef1d70d6f0a6f4b7612d2c5f7a specs: premailer (1.7.3) css_parser (>= 1.1.9) htmlentities (>= 4.0.0) GIT remote: git://github.com/tomazzlender/snapshot.git revision: 0f0f3fd024bf5a3a846e999b845803ae61d870c0 specs: snapshot (1.1.0) GIT remote: https://github.com/37signals/mail_view.git revision: c8cc1315026ce85973ef56e628ac2e38a7a95563 specs: mail_view (1.0.1) tilt GIT remote: https://github.com/thoughtbot/capybara-webkit.git revision: 11c596f7a06dbda123c077440f9275905f89e869 specs: capybara-webkit (0.13.0) capybara (>= 2.0.1) json GEM remote: https://rubygems.org/ specs: actionmailer (3.2.17) actionpack (= 3.2.17) mail (~> 2.5.4) actionpack (3.2.17) activemodel (= 3.2.17) activesupport (= 3.2.17) builder (~> 3.0.0) erubis (~> 2.7.0) journey (~> 1.0.4) rack (~> 1.4.5) rack-cache (~> 1.2) rack-test (~> 0.6.1) sprockets (~> 2.2.1) active_attr (0.7.0) activemodel (>= 3.0.2, = 3.0.2,  3.0.0) activerecord (3.2.17) activemodel (= 3.2.17) activesupport (= 3.2.17) arel (~> 3.0.2) tzinfo (~> 0.3.29) activeresource (3.2.17) activemodel (= 3.2.17) activesupport (= 3.2.17) activesupport (3.2.17) i18n (~> 0.6, >= 0.6.4) multi_json (~> 1.0) addressable (2.2.7) ansi (1.4.3) arel (3.0.3) authlogic (3.1.0) activerecord (>= 3.0.7) activerecord (>= 3.0.7) builder (3.0.4) capistrano (2.9.0) highline net-scp (>= 1.0.0) net-sftp (>= 2.0.0) net-ssh (>= 2.0.14) net-ssh-gateway (>= 1.1.0) capybara (2.0.2) mime-types (>= 1.16) nokogiri (>= 1.3.3) rack (>= 1.0.0) rack-test (>= 0.5.4) selenium-webdriver (~> 2.0) xpath (~> 1.0.0) childprocess (0.3.6) ffi (~> 1.0, >= 1.0.6) chronic (0.6.7) 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.2.0) css_parser (1.2.6) addressable rdoc erubis (2.7.0) eventmachine (1.0.0) exception_notification (3.0.0) actionmailer (>= 3.0.4) tinder (~> 1.8) execjs (1.3.0) multi_json (~> 1.0) faraday (0.8.4) multipart-post (~> 1.1) faraday_middleware (0.9.0) faraday (>= 0.7.4, = 3.1.0,  0.14) json (1.8.1) kgio (2.7.2) launchy (2.1.0) addressable (~> 2.2.6) libwebsocket (0.1.7.1) addressable websocket mail (2.5.4) mime-types (~> 1.16) treetop (~> 1.4.8) marginalia (1.1.0) actionpack (>= 2.3, = 2.3, = 1.0) minitest-matchers (>= 1.2) minitest-matchers (1.2.0) minitest (>= 2.5.0) minitest-rails (0.3) minitest (~> 4.0) rails (~> 3.0) minitest-rails-capybara (0.1) minitest-capybara (~> 0.1) minitest-rails (~> 0.1) multi_json (1.9.0) multipart-post (1.1.5) net-scp (1.0.4) net-ssh (>= 1.99.1) net-sftp (2.0.5) net-ssh (>= 2.0.9) net-ssh (2.3.0) net-ssh-gateway (1.1.0) net-ssh (>= 1.99.1) nokogiri (1.5.0) pg (0.17.1) polyglot (0.3.4) premailer-rails3 (1.3.1) premailer (~> 1.7) rails (~> 3) psych (1.3.4) quiet_assets (1.0.1) railties (~> 3.1) rack (1.4.5) rack-cache (1.2) rack (>= 0.4) rack-contrib (1.1.0) rack (>= 0.9.1) rack-ssl (1.3.3) rack rack-test (0.6.2) rack (>= 1.0) rails (3.2.17) actionmailer (= 3.2.17) actionpack (= 3.2.17) activerecord (= 3.2.17) activeresource (= 3.2.17) activesupport (= 3.2.17) bundler (~> 1.0) railties (= 3.2.17) railties (3.2.17) actionpack (= 3.2.17) activesupport (= 3.2.17) rack-ssl (~> 1.3.2) rake (>= 0.8.7) rdoc (~> 3.4) thor (>= 0.14.6,  1.4) ruby-ole (1.2.11.3) rubyzip (0.9.6.1) sass (3.2.6) sass-rails (3.2.6) railties (~> 3.2.0) sass (>= 3.1.10) tilt (~> 1.3) selenium-webdriver (2.27.2) childprocess (>= 0.2.5) libwebsocket (~> 0.1.3) multi_json (~> 1.0) rubyzip sheets (1.1.0) nokogiri (>= 1.4.3.1) rubyzip (>= 0.9.4) spreadsheet (>= 0.6.5.2) simple_oauth (0.1.9) spreadsheet (0.6.8) ruby-ole (>= 1.0) sprockets (2.2.2) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) thor (0.18.1) tilt (1.4.1) tinder (1.9.1) eventmachine (>= 0.12.0,  0.8) faraday_middleware (~> 0.8) hashie (~> 1.0) json (~> 1.6) mime-types (~> 1.16) multi_json (~> 1.0) multipart-post (~> 1.1) twitter-stream (~> 0.1) treetop (1.4.15) polyglot polyglot (>= 0.3.1) turn (0.9.6) ansi twitter-stream (0.1.16) eventmachine (>= 0.12.8) http_parser.rb (~> 0.5.1) simple_oauth (~> 0.1.4) tzinfo (0.3.39) uglifier (1.2.3) execjs (>= 0.3.0) multi_json (>= 1.0.2) unicode_utils (1.3.0) unicorn (4.2.0) kgio (~> 2.6) rack raindrops (~> 0.7) websocket (1.0.6) whenever (0.7.3) activesupport (>= 2.3.4) chronic (~> 0.6.3) will_paginate (3.0.3) xpath (1.0.0) nokogiri (~> 1.3) PLATFORMS ruby DEPENDENCIES active_attr authlogic capistrano capybara capybara-webkit! coffee-rails (~> 3.2.1) exception_notification (= 3.0.0) jquery-rails (~> 2.0.1) launchy letter_opener! mail_view! marginalia meta_request (= 0.2.1) minitest-rails minitest-rails-capybara nokogiri pg premailer! premailer-rails3 psych quiet_assets rails (= 3.2.17) sass (= 3.2.6) sass-rails (~> 3.2.3) sheets snapshot! turn uglifier (>= 1.0.3) unicode_utils unicorn whenever will_paginate 

是什么导致这个错误?

这是当前版本的Sass的已知错误,更新sass样式表将导致缓存错误,因为Sprockets导入器未正确序列化。 对于错误报告,请看这个 。

这是链轮中的一个错误,但如果像我一样使用旧版本的Rails(3.2),您可以通过使用不同版本的sass来修复错误。 这家伙能够使用sass 3.1.x : https : //github.com/rails/sass-rails/issues/242#issuecomment-66231135

这里提到的线程提供了一些良好的上下文和解释如何处理解决问题或解决无法升级到更新,固定版本的链轮。

基本上,在支持Rails 3.2.x的时候使用sass / sass-rails / sprockets。