【问题标题】:rake assets:precompile aborting, can't push to herokurake 资产:预编译中止,无法推送到 heroku
【发布时间】:2012-07-11 19:11:38
【问题描述】:

我正在使用 Enki 博客 gem,它在本地工作,试图准备推送到 heroku(以前从未遇到过问题)。我试图预编译,它做到了这一点

/Users/me/.rvm/rubies/ruby-1.9.3-rc1/bin/ruby /Users/me/.rvm/gems/ruby-1.9.3-rc1@ruby193/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
cannot load such file -- uglifier
  (in /Users/me/Sites/bayani/app/assets/javascripts/admin.js)

我以前从来没有遇到过将 Enki 博客推送到 Heroku 的问题,虽然我不知道 uglifier 在哪里,但我记得在我推送过的其他 Enki 博客中看到过它,所以我不知道为什么会这样现在制造问题。

当我推送到 Heroku 时,它也终止了预编译

Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       no such file to load -- uglifier
       (in /tmp/build_5tbsi7k7ddhk/app/assets/javascripts/admin.js)
       Tasks: TOP => assets:precompile:primary
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

在阅读了它提供的链接上的故障排除文章后,我把它放在了 application.rb 中

config.assets.initialize_on_precompile = false

但我仍然遇到同样的问题

这是 admin.js。它只是一个清单文件。这是enki的链接https://github.com/xaviershay/enki

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
// GO AFTER THE REQUIRES BELOW.
//
//= require jquery
//= require jquery_ujs
//= require jquery.livequery
//= require jquery.form
//= require jquery.easing.1.3
//= require humanmsg
//= require_tree ./admin

【问题讨论】:

    标签: ruby-on-rails heroku


    【解决方案1】:

    将以下内容添加到 Gemfile。

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

    运行

    捆绑安装

    rake assets:预编译

    希望对你有用。

    【讨论】:

    • 问题中写的错误信息指出了Gemfile中没有包含uglifier gem的问题。因此,我只需要在 Gemfile 的资产组中添加 uglifier gem。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-19
    • 1970-01-01
    • 2014-04-20
    • 1970-01-01
    相关资源
    最近更新 更多