错误推送到Heroku - 中止我的耙资产:预编译 [英] Error pushing to heroku - aborting my rake assets:precompile

查看:73
本文介绍了错误推送到Heroku - 中止我的耙资产:预编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

继我的Git Push Heroku Master之后,我遇到了一些问题Heroku的。这里是最新最好的,放弃了rake资产:precompile。

  ----->为Rails资产管道准备应用程序
运行:rake资产:预编译
rake中止!
无法连接到服务器:连接被拒绝
服务器是否在主机127.0.0.1上运行并接受端口5432上的
TCP / IP连接?
任务:TOP =>环境
(通过使用--trace运行任务查看完整跟踪)
预编译资产失败,启用运行时资产编译
注入rails31_enable_runtime_asset_compilation
请参阅本文以获取故障诊断帮助:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

下面包含内容我的Gemfile:

  gem'rails','3.2.8'
gem'bootstrap-sass',' 2.1'
gem'pg'

group:development,:test do
gem'rspec-rails'
gem'guard-rspec'
gem 'guard-spork'
gem'spork'
gem'annotate'
gem'database_cleaner'
end

Gems只用于资产而不用在生产环境中默认需要
#。
group:assets do
gem'sass-rails','〜> 3.2.3'
end

平台:jruby do
gem'trinidad'
gem'jruby-openssl'
end

gem'jquery-rails'

#使用独角兽作为web服务器
#gem'unicorn'

#使用Capistrano部署
#gem 'capistrano'

#使用调试器
#gem'ruby-debug'

#捆绑额外的宝石:
gem'RedCloth',' 〜> 4.2.9',:require => 'redcloth'
gem'ruby-openid',:require => 'openid'
gem'rack-openid',:require => 'rack / openid'
gem'aaronh-chronic',:require => 'chronic'#修正为1.9.2
gem'coderay'
gem'lesstile'
gem'formtastic'
gem'will_paginate','〜> 3.0.2'
gem'exception_notification','〜> 2.5.2'
gem'open_id_authentication'

#为本地环境捆绑宝石。确保
#在此组中放置纯测试宝石,以便它们的生成器
#和rake任务可用于开发模式:
group:test do
gem'database_cleaner'
gem'cucumber-rails',:require => false
gem'cucumber-websteps',:require => false
gem'factory_girl'
gem'rspec'
gem'nokogiri','〜> 1.5.0'
gem'webrat'
end

可能是什么问题?



更新::我使用--trace运行rake命令,并且因为生产数据库没有存在。我创建了数据库,然后再次运行--trace,这就是我现在正在抛出的东西:

 命令失败,并显示状态(1):[/usr/local/Cellar/ruby/1.9.3-p286/bin/ruby ...] 


解决方案

请参阅 Heroku Cedar上的Rails 3.1+资产管道文章。简单来说,您的Heroku应用程序在构建(包括资产编译)和运行(您的应用程序变得可用的地方)之间有很强的分离)。这与 12因子应用原则一致,但这意味着您的应用无法访问在构建阶段任何配置的资源 - 包括数据库 - 意味着资产预编译期间ActiveRecord不可用。



您可以告诉Rails不要在资产编译期间引导您的应用程序 config / application.rb

  config.assets.initialize_on_precompile = false 

故障排除部分还建议:


如果rake资产:precompile仍然不起作用,您可以在本地进行调试,方法是在本地 config / database.yml 中配置一个不存在的数据库并尝试运行 rake资产:预编译。理想情况下,您应该能够在不连接数据库的情况下运行此命令。



Edit: I'm a new ruby on rails student.

Following my Git Push Heroku Master, I am running into issues with Heroku. Here is the latest and greatest, aborting the rake assets:precompile.

-----> Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   could not connect to server: Connection refused
   Is the server running on host "127.0.0.1" and accepting
   TCP/IP connections on port 5432?
   Tasks: TOP => environment
   (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

Included below are the contents of my Gemfile:

gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.1'
gem 'pg'

group :development, :test do
  gem 'rspec-rails'
  gem 'guard-rspec'
  gem 'guard-spork'
  gem 'spork'
  gem 'annotate'
  gem 'database_cleaner'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
end

platforms :jruby do
  gem 'trinidad'
  gem 'jruby-openssl'
end

gem 'jquery-rails'

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug'

# Bundle the extra gems:
gem 'RedCloth', '~> 4.2.9', :require => 'redcloth'
gem 'ruby-openid', :require => 'openid'
gem 'rack-openid', :require => 'rack/openid'
gem 'aaronh-chronic', :require => 'chronic' # Fixes for 1.9.2
gem 'coderay'
gem 'lesstile'
gem 'formtastic'
gem 'will_paginate', '~> 3.0.2'
gem 'exception_notification', '~> 2.5.2'
gem 'open_id_authentication'

# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
  gem 'database_cleaner'
  gem 'cucumber-rails',    :require => false
  gem 'cucumber-websteps', :require => false
  gem 'factory_girl'
  gem 'rspec'
  gem 'nokogiri', '~> 1.5.0'
  gem 'webrat'
end

What might be the issue?

Update: I ran the rake command with --trace, and it had alerted me with a failure because the production database did not exist. I created the database, and ran --trace again, and this is what I'm currently being thrown:

Command failed with status (1): [/usr/local/Cellar/ruby/1.9.3-p286/bin/ruby...]

解决方案

See the Rails 3.1+ Asset Pipeline on Heroku Cedar article. This exact scenario is covered in the Troubleshooting section.

In short, your Heroku application has a strong separation between building (including asset compilation) and running (where your application becomes available). This is consistent with the 12-factor app principles, but it means that your application cannot access any configured resources during the build phase -- including the database -- meaning ActiveRecord is unavailable during asset precompilation.

You can tell Rails not to bootstrap your application during asset compilation in config/application.rb:

config.assets.initialize_on_precompile = false

The troubleshooting section also recommends:

If rake assets:precompile is still not working, you can debug this locally by configuring a nonexistent database in your local config/database.yml and attempting to run rake assets:precompile. Ideally you should be able to run this command without connecting to the database.

这篇关于错误推送到Heroku - 中止我的耙资产:预编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆