2

我最近在 Heroku 上遇到了这个问题,似乎无法弄清楚如何纠正它。该应用程序是在 ruby​​ 1.9.3 上运行的 Rails 3.2.x 应用程序。它在本地运行良好,但是当部署到 heroku 时,资产的预编译阶段失败。heroku web dyno stack 是 cedar。

我已经在 application.rb 文件中设置了 'config.assets.initialize_on_precompile = false'。

以下是部署时收到的错误。

Counting objects: 7, done.
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 438 bytes, done.
Total 4 (delta 3), reused 0 (delta 0)

-----> Ruby/Rails app detected
-----> Using Ruby version: ruby-1.9.3
-----> Installing dependencies using Bundler version 1.3.2
    Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin --deployment
    Using rake (10.0.3)
    Using i18n (0.6.4)
    Using multi_json (1.6.1)
    Using activesupport (3.2.12)
    Using builder (3.0.4)
    Using activemodel (3.2.12)
    Using erubis (2.7.0)
    Using journey (1.0.4)
    Using rack (1.4.5)
    Using rack-cache (1.2)
    Using rack-test (0.6.2)
    Using hike (1.2.1)
    Using tilt (1.3.4)
    Using sprockets (2.2.2)
    Using actionpack (3.2.12)
    Using mime-types (1.21)
    Using polyglot (0.3.3)
    Using treetop (1.4.12)
    Using mail (2.4.4)
    Using actionmailer (3.2.12)
    Using arel (3.0.2)
    Using tzinfo (0.3.35)
    Using activerecord (3.2.12)
    Using activeresource (3.2.12)
    Using bcrypt-ruby (3.0.1)
    Using coffee-script-source (1.5.0)
    Using execjs (1.4.0)
    Using coffee-script (2.2.0)
    Using rack-ssl (1.3.3)
    Using json (1.7.7)
    Using rdoc (3.12.2)
    Using thor (0.17.0)
    Using railties (3.2.12)
    Using coffee-rails (3.2.2)
    Using orm_adapter (0.4.0)
    Using warden (1.2.1)
    Using devise (2.2.3)
    Using jquery-rails (2.2.1)
    Using pg (0.12.2)
    Using bundler (1.3.2)
    Using rails (3.2.12)
    Using rubygems-bundler (1.1.1)
    Using sass (3.2.6)
    Using sass-rails (3.2.6)
    Using uglifier (1.3.0)
    Your bundle is complete! It was installed into ./vendor/bundle
    Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
    Running: rake assets:precompile
    rake aborted!
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/coffee-rails-3.2.2/lib/rails/generators/coffee/assets/templates/javascript.js.coffee isn't in paths: /tmp/build_18zpsldi56ucr/app/assets/images, /tmp/build_18zpsldi56ucr/app/assets/javascripts, /tmp/build_18zpsldi56ucr/app/assets/stylesheets, /tmp/build_18zpsldi56ucr/vendor/assets/fonts, /tmp/build_18zpsldi56ucr/vendor/assets/javascripts, /tmp/build_18zpsldi56ucr/vendor/assets/stylesheets, /tmp/build_18zpsldi56ucr/vendor/assets/venera_images, /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/coffee-rails-3.2.2/lib/assets/javascripts, /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/jquery-rails-2.2.1/vendor/assets/javascripts
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/asset_attributes.rb:42:in `logical_path'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:160:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:111:in `block in resolve_dependencies'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `each'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:105:in `resolve_dependencies'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:97:in `build_required_assets'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:16:in `initialize'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/static_compiler.rb:19:in `block in compile'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:219:in `block in each_logical_path'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:206:in `block (2 levels) in each_file'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:196:in `each_entry'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:204:in `block in each_file'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:203:in `each_file'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/sprockets-2.2.2/lib/sprockets/base.rb:217:in `each_logical_path'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/static_compiler.rb:18:in `compile'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:56:in `internal_precompile'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:70:in `block (3 levels) in <top (required)>'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
    /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
    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
-----> Rails plugin injection
    Injecting rails_log_stdout
    Injecting rails3_serve_static_assets
-----> Discovering process types
    Procfile declares types     -> (none)
    Default types for Ruby/Rails -> console, rake, web, worker

-----> Compiled slug size: 20.8MB
-----> Launching... done, v25

宝石文件:

source 'https://rubygems.org'

gem 'rails', '3.2.12'
gem 'jquery-rails', '~> 2.2.1'

gem 'rubygems-bundler', '~> 1.1.1'
gem 'devise', '~> 2.2.3'

group :development, :test do
  gem 'sqlite3', '~> 1.3.7'
  gem 'rspec-rails', '~> 2.13.0'
  gem 'annotate', '~> 2.5.0'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails', '~> 3.2.6'
  gem 'coffee-rails', '~> 3.2.2'
  gem 'uglifier', '>= 1.3.0'
end

group :test do
  gem 'capybara', '1.1.2'
end

group :production, :staging do
  gem 'pg', '0.12.2'
end

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# To use debugger
# gem 'debugger'

应用程序.css

/*
 * 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 .
 *= require_tree ../../../vendor
 */

应用程序.js

// 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_tree .
//= require_tree ../../../vendor

这应该在 ruby​​ 1.9.3 上运行,但我在 gems 路径中看到 /tmp/build_18zpsldi56ucr/vendor/bundle/ruby/1.9.1/gems/ 。不确定这是否是问题所在。以前有没有人在heroku上遇到过这个问题。谢谢。

4

1 回答 1

0

由于该:assets组下的宝石不用于生产,因此您应该将该gem 'coffee-rails'行移出该组。

另外我认为您的 application.js 中不需要这一*= require_tree ../../../vendor

于 2013-05-19T10:56:44.270 回答