【问题标题】:Heroku rake assets:precompile failed to compile Rails appHeroku rake 资产:预编译无法编译 Rails 应用程序
【发布时间】:2014-04-20 05:51:14
【问题描述】:

我没有对我的资产进行任何更改,现在突然间当我执行 git push heroku master 它在 rake assets:precompile 上中止p>

...

Preparing app for Rails asset pipeline
Running: rake assets:precompile
I, [2014-03-14T18:30:05.776041 #675]  INFO -- : Writing /tmp/build_f664cf41-71b7-435d-b85e-8f607080a4d3/public/assets/application-0a41bdbc9b8fc13f1e62a69634eb2c98.js
rake aborted!
wrong number of arguments (2 for 1)
(in /tmp/build_f664cf41-71b7-435d-b85e-8f607080a4d3/app/assets/stylesheets/application.css.scss)
/tmp/build_f664cf41-71b7-435d-b85e-8f607080a4d3/vendor/bundle/ruby/2.0.0/gems/sass-3.2.14/lib/sass/importers/filesystem.rb:16:in `initialize'
/tmp/build_f664cf41-71b7-435d-b85e-8f607080a4d3/vendor/bundle/ruby/2.0.0/gems/sprockets-2.12.0/lib/sprockets/sass_importer.rb:11:in `initialize'

...

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
!
!     Precompiling assets failed.
!

!     Push rejected, failed to compile Ruby app

它似乎是由于 assets/stylesheets/application.css.scss 中的参数数量错误(2 比 1) 而中断。但是我的样式表中没有任何方法。 这是那个文件:

/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the top of the
* compiled file, but it's generally better to create a new file per style scope.
*
*= require_self
*= require_tree .
*/

在我的 assets/stylesheets/custom.css.scss 我在顶部有这个:

@import 'bootstrap';
@import 'bootstrap-responsive';

在我的 config/application.rb 文件中,我有:

config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif)
config.assets.initialize_on_precompile = false

我执行了 heroku run rake assets:clobber,但没有帮助。

本地我的应用程序运行良好。

以下是我用来参考的一些宝石:

gem 'sass-rails'
gem 'bootstrap-sass', '2.3.2.0'
gem 'rails_12factor'
gem 'compass_rails'
gem 'jquery-rails'
gem 'rails', '4.0.2'

有什么想法吗?

【问题讨论】:

    标签: ruby-on-rails heroku assets precompile


    【解决方案1】:

    只需像这样添加/修改 Gemfile 依赖 sass-rails

    gem 'sass-rails', '4.0.2'
    

    这种修改解决了我的问题。

    【讨论】:

      【解决方案2】:

      好的。我发现了问题。

      gem 'sass-rails' 使用的是版本 3.2.14。通过更新到 4.0.2,我能够在部署到 Heroku 时预编译我的资产。

      一切都好。

      【讨论】:

      • 非常感谢!奇怪的是,我的 Gemfile 中没有指定特定版本,但是运行 bundle update 并没有更新 sass-rails gem。我必须手动指定版本 4.0.2
      猜你喜欢
      • 2012-09-02
      • 1970-01-01
      • 2014-02-19
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      • 1970-01-01
      • 2012-04-04
      • 2012-07-11
      相关资源
      最近更新 更多