【问题标题】:"rake aborted! stack level too deep" while deploying to Heroku部署到 Heroku 时出现“rake aborted!stack level too deep”
【发布时间】:2012-04-04 11:40:33
【问题描述】:

我的网站过去可以正常工作,Heroku 预编译了资产和所有内容。现在,似乎不知从何而来,我开始在部署时收到此消息:

Preparing app for Rails asset pipeline
Running: rake assets:precompile
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets/icons
mkdir -p /tmp/build_31cexir1p9pwn/public/assets/icons
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
(in /tmp/build_31cexir1p9pwn)
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
mkdir -p /tmp/build_31cexir1p9pwn/public/assets
rake aborted!
stack level too deep
(in /tmp/build_31cexir1p9pwn/app/assets/stylesheets/theme.css.scss)

(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation

它无法预编译我的 css 文件。

我正在使用 cedar 堆栈,这是我的 gemfile:

gem 'rails', '3.1.0'
gem 'rake', '0.8.7'
gem 'devise'

group :production do
  gem 'pg'
  gem 'thin'
end

group :assets do
  gem 'sass-rails', "  ~> 3.1.0"
  gem 'coffee-rails', "~> 3.1.0"
  gem 'uglifier'
end

这是我的 application.rb 文件

# Enable the asset pipeline
config.assets.enabled = true

# Version of your assets, change this if you want to expire all your assets.
config.assets.version = '1.0'

这是我的 production.rb 文件

# Code is not reloaded between requests
config.cache_classes = true

# Full error reports are disabled and caching is turned on
config.consider_all_requests_local       = false
config.action_controller.perform_caching = true

# Enable Rails's static asset server (Apache or nginx will not need this)
config.serve_static_assets = true

# Set expire header of 30 days for static files
config.static_cache_control = "public, max-age=2592000"

# Allow JavaScript and CSS compression
config.assets.compress = true

# Compress JavaScript by removing whitespace, shortening variable names, ...
config.assets.js_compressor = :uglifier

# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = true

现在我所有的图片链接都被破坏了(我在我的 css 文件中使用了 image-url())。可能是什么问题,我该如何解决?

【问题讨论】:

  • 你能列出这个文件,theme.css.scss。您的资产管道似乎溢出了
  • “堆栈级别太深”错误实际上是应用程序内存不足的情况。这通常是程序使用大量递归(调用自身的函数)的结果,而解析器(SASS 到 CSS,CoffeeScript 到 JS,ERB 到 HTML)通常会使用递归。作为一种变通方法,请在部署之前尝试预编译资产 - 您的本地计算机上的内存可能比 Heroku 实例更多。
  • 这是一个非常严重的错误。你在github上举报了吗?
  • 已经被举报了。这就是答案所在。 github.com/rails/sass-rails/issues/78

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


【解决方案1】:

对于 ruby​​ 2.3.0 或更低版本,Rails 的 application.rb 文件中有以下行。但 2.4.0 或更高版本已将这些实现为自动化。

Bundler.require(*Rails.groups)

将 ruby​​ 版本更改为 2.3.0 就可以了。这个拯救了我的一天。

【讨论】:

    【解决方案2】:

    升级到 sass v3.2.12 对我有用

    但总体而言,该问题似乎在所有当前版本上都已修复,只需进行捆绑更新即可。

    【讨论】:

      【解决方案3】:

      我真的很绝望,所以我asked another question。显然这是由 sass 引起的,降级到 sass-rails v3.1.4 v3.2.5 将使其正常工作。

      【讨论】:

        猜你喜欢
        • 2011-08-22
        • 2018-03-18
        • 1970-01-01
        • 2012-09-12
        • 1970-01-01
        • 2015-07-03
        • 1970-01-01
        • 1970-01-01
        • 2021-04-09
        相关资源
        最近更新 更多