【问题标题】:Heroku: Error encountered while saving cacheHeroku:保存缓存时遇到错误
【发布时间】:2014-04-12 04:31:02
【问题描述】:

在本地一切正常,但在推送到 Heroku 时:

   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/bc1b787c8640c68bf42fc69efbef227d36428060/_carousel.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/bc1b787c8640c68bf42fc69efbef227d36428060/_hero-unit.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/bc1b787c8640c68bf42fc69efbef227d36428060/_utilities.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/exams.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/home.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/lessons.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/questions.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/scaffolds.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>
   Warning. Error encountered while saving cache /tmp/build_1b5c442a-d24e-4f80-9755-a0bd15d7f029/tmp/cache/sass/5b1569a9810eac207f22942f2921f0820863a2d6/sections.css.scssc: can't dump anonymous class #<Class:0x007f2583f02288>

最终我得到:

   Warning. Error encountered while saving cache /tmp/build_ccaceaf0-2d8f-4d84-8284-9f5fcb7ced3f/tmp/cache/sass/6b13061e65d1f1cd905accb7f7211a333a70c956/sections.css.scssc: can't dump anonymous class #<Class:0x007f02dbceaa88>
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_ccaceaf0-2d8f-4d84-8284-9f5fcb7ced3f/Rakefile:7)
   DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_ccaceaf0-2d8f-4d84-8284-9f5fcb7ced3f/Rakefile:7)

 !     Timed out compiling Ruby app (15 minutes)
 !     See https://devcenter.heroku.com/articles/slug-compiler#time-limit

我只粘贴了这个出现次数的一小部分。

我的宝石文件:

ruby '2.0.0'
gem 'rails', '3.2.11'
group :assets do
  gem 'sass-rails' #,   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'
  gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
gem 'bootstrap-sass'#, '2.3.2.0'
gem 'cancan'
gem 'devise'
gem 'figaro'
gem 'haml-rails'
gem 'mongoid'
gem 'rolify'
gem 'simple_form'
gem 'thin'
gem 'country_select'
group :development do
  gem 'better_errors'
  gem 'binding_of_caller', :platforms=>[:mri_19, :rbx]
  gem 'guard-bundler'
  gem 'guard-rails'
  gem 'guard-rspec'
  gem 'html2haml'
  gem 'quiet_assets'
  gem 'rb-fchange', :require=>false
  gem 'rb-fsevent', :require=>false
  gem 'rb-inotify', :require=>false
  gem "switch_user"
end
group :development, :test do
  gem 'factory_girl_rails'
  gem 'rspec-rails'
end
group :test do
  gem 'database_cleaner'
  gem 'email_spec'
  gem 'mongoid-rspec'
end
gem "ckeditor"
#gem "binding_of_caller"
gem "mongoid-paperclip", :require => "mongoid_paperclip", :git=>'https://github.com/meskyanichi/mongoid-paperclip'
gem 'aws-sdk', '~> 1.3.4'
gem "flat-ui-rails"
gem 'stripe', :git => 'https://github.com/stripe/stripe-ruby'
gem "mongoid_slug", "~> 2.0.1"

我的 production.rb 文件启用了以下属性

  config.cache_classes = true

  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  config.serve_static_assets = true

  config.assets.compress = true
  config.assets.compile = false

  config.assets.digest = true
  config.assets.initialize_on_precompile = false

我的 Rails 版本是 Rails 3.2.11

【问题讨论】:

  • 看到同样的事情,除了我的应用程序最终编译并启动并且似乎工作正常(我猜我的错误并没有导致它超过 15 分钟超时)。这是我自 status.heroku.com/incidents/596 以来的第一次推送。 . .想知道他们是否会做一些事情?你用 Heroku 创建了一张票吗?我的应用没有重大变化,所以我相信我没有破坏任何东西。
  • 这对你有用吗?
  • 如果这对您有用,请标记为已接受的答案。谢谢!
  • @bcb 我最终做的是在本地预编译资产然后推送。

标签: ruby-on-rails ruby-on-rails-3 heroku


【解决方案1】:

这与最近将 sass gem 升级到 3.3.0 有关。 sass gem 是其他几个 sass gem 的依赖项,因此即使您的 Gemfile 中没有它,它也可能正在加载。在本地和 Heroku 上做一个“捆绑秀”,我很确定你会看到它们是不同的版本(几天前 sass 升级到 3.3.0)。

添加:

gem 'sass', '3.2.13'

到您的 Gemfile,这应该会为您解决问题。然后去 github 上为这个 gem 提交一个 issue。

希望这有帮助,它对我有用!

【讨论】:

  • 为我工作。虽然有点令人沮丧,因为 1. 我们不知道什么时候可以删除行 2. 我不知道是否应该在 group :assets 中添加行 ...
  • 也为我工作......真的很烦人...... font-awesome-sass-rails,sass-rails。 sass-rails 专门不锁定 sass 版本。谢谢你。
  • 在 3.2.19 中仍然会发生这种情况 :( .
  • 对我来说,它们不是不同的版本。但我仍然收到此错误。
【解决方案2】:

这是 Sass 3.3.0 中的一个已知错误,Sprockets 导入器未序列化,因此无法缓存导致此错误。有关错误报告,请参阅this。如果没有缓存,Sass 编译速度会非常慢,这会导致 heroku 服务器超时。

【讨论】:

    【解决方案3】:

    首先你可能想要更新

    bundle update sass-rails
    bundle update sass
    

    然后是更关键的部分(确保卸载 Gemfile.lock 中的 sass 版本)

    gem uninstall sass
    bundle install
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-21
      • 2021-09-18
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 2014-04-12
      • 2021-10-21
      相关资源
      最近更新 更多