rake assets:precompile中止,无法推送到Heroku。

4

我正在使用Enki博客宝石,它在本地工作得很好,现在正在准备推送到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)

我以前从未在Heroku上推送Enki博客时遇到过问题,虽然我不知道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
1个回答

13

将以下内容添加到Gemfile。

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

运行

bundle install

rake assets:precompile

我希望它会有用。


问题中的错误信息指向了一个问题,即uglifier宝石没有被包含在Gemfile中。因此,我只需要在Gemfile的资产组中要求uglifier宝石即可。 - Mieczysław Daniel Dyba

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接