Heroku上传 - 预编译资产失败 [英] Heroku upload-Precompiling assets failed

查看:126
本文介绍了Heroku上传 - 预编译资产失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要帮助。当试图将我的应用程序上传到heroku时,出现此错误,任何人都知道为什么?有几个是错的。谢谢

 使用rake(10.1.0)
...
使用tlsmail(0.0.1)
使用uglifier(2.1.2)
您的套件已完成!它被安装到./vendor/bundle
----->编写config / database.yml以从DATABASE_URL读取
----->为Rails资产管道准备应用程序
运行:rake资产:预编译
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1 /lib/net/smtp.rb:806:警告:已经初始化常量SMTPSession
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1 /gems/tlsmail-0.0.1/lib/net/pop.rb:702:警告:已经初始化常量APOPSession
DEPRECATION警告:在供应商/插件中有Rails 2.3风格的插件!在Rails 4.0中将会删除对这些插件的支持。将它们移出并将它们捆绑到Gemfile中,或者将它们作为lib / myplugin / *和config / initializers / myplugin.rb折叠到您的应用程序中。有关更多信息,请参阅发行说明:http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released。 (在/ tmp / build_e8889be5-168c-49ed-81e7-b71061fc82ee / Rakefile中从< top(required)>调用)7)
...
rake中止!
无法连接到服务器:连接被拒绝
服务器是否在主机127.0.0.1上运行并接受端口5432上的
TCP / IP连接?
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in`initialize '
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in`新'
...
/tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.12/lib/sprockets/assets。 rake:29:在< top(required)>'
'块中(2个等级)任务:TOP =>环境
(通过使用--trace运行任务查看完整跟踪)

!预编译资产失败。


解决方案

Heroku文档


这意味着您的应用程序是试图连接到数据库作为rake资产的一部分:预编译。由于config vars不在环境中,我们使用占位符DATABASE_URL来满足Rails。


要解决此问题,请确保您的 config / application.rb 中会出现以下行:
$ b

 # config / application.rb 
config.assets.initialize_on_precompile = false

添加完成后,更改并重新部署到Heroku - 您的资产应该在您的应用程序尝试连接到数据库的情况下进行编译,这应该可以解决您正在见证的错误。

更新

第46行堆栈跟踪包含以下消息:未设置Devise.secret_key。



根据Devise的作者JoséValim ,可以通过以下方式解决此问题:


请添加以下内容您的设计初始值设定项:

config.secret_key =' - 密钥 - '


或者以下解决方案似乎有为许多用户工作:


我去了我的routes.rb文件并注释掉了devise_for行:installs



然后我回去并重新登录ge nerate设计:安装。如果这不起作用,通过编辑你的Gemfile对Devise的引用来像这样使用以前版本的设计:gem'devise','3.0.3',然后按照上面提到的步骤操作。



I need help. When trying to upload my app to heroku, I get this error, anyone know why? A few was wrong. thanks

       Using rake (10.1.0)
       ...
       Using tlsmail (0.0.1)
       Using uglifier (2.1.2)
       Your bundle is complete! It was installed into ./vendor/bundle
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/smtp.rb:806: warning: already initialized constant SMTPSession
       ...
       /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/tlsmail-0.0.1/lib/net/pop.rb:702: warning: already initialized constant APOPSession
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/Rakefile:7)
       ...
       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?
       /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
       /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.12/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
       ...
       /tmp/build_e8889be5-168c-49ed-81e7-b71061fc82ee/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 => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.

解决方案

From the Heroku docs:

This means that your app is attempting to connect to the database as part of rake assets:precompile. Because the config vars are not present in the environment, we use a placeholder DATABASE_URL to satisfy Rails.

To resolve this issue, ensure that the following line appears in your config/application.rb:

# config/application.rb
config.assets.initialize_on_precompile = false

Once added, commit your change and redeploy to Heroku – your assets should compile without your app attempting to connect to the database, which should resolve the error you're witnessing.

UPDATE:

Line 46 of your stacktrace includes the following message: Devise.secret_key was not set.

According to the author of Devise, José Valim, this issue can be resolved in the following manner:

Please add the following to your Devise initializer:

config.secret_key = '-- secret key --'

Alternatively, the following solution seems to have worked for a number of users:

I went to my routes.rb file and commented out the line devise_for :installs

Then I went back and reran rails generate devise:install. If that doesn't work, use the previous version of devise by editing your Gemfile's reference to Devise like this: gem 'devise', '3.0.3' and then follow the steps i mentioned above.

这篇关于Heroku上传 - 预编译资产失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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