gpt4 book ai didi

ruby-on-rails - rails Assets :precompile during slug for s3 error: Fog provider and directory can't be blank when env are set

转载 作者:行者123 更新时间:2023-12-04 06:28:49 25 4
gpt4 key购买 nike

我决定通过 S3 为 Rails Assets 提供服务; heroku 有关于如何做到这一点的很棒的教程。该站点现在正在从我的亚马逊存储桶中提供 Assets ,但我不确定为什么我必须在运行 git push heroku master 之后手动运行rake assets:precompile

运行 git push heroku master 后, Assets 不在我的桶中,预编译的输出是:

AssetSync: using default configuration from built-in initializer
AssetSync: using default configuration from built-in initializer
rake aborted!
Fog provider can't be blank, Fog directory can't be blank
/tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/asset_sync/asset_sync.rb:29:in `sync'
/tmp/build_3vtwfg15g8ajx/vendor/bundle/ruby/1.9.1/gems/asset_sync-0.5.0/lib/tasks/asset_sync.rake:3:in `block in <top (required)>'
Tasks: TOP => assets:precompile:nondigest
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation

我确实设置了 fog provider 和目录:heroku config:add FOG_DIRECTORY=XXX FOD_PROVIDER=AWS 并调用 heroku config --app 确认了这一点...所以我没有得到这些错误.

Assets 没有出现在我的存储桶中,所以我运行:heroku run rake assets:precompile 一切正常,但出现警告:

AssetSync: using default configuration from built-in initializer
AssetSync: Syncing.
[WARNING] fog: the specified s3 bucket name(ss_assets) is not a valid dns name, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/Bucket
Restrictions.html

我是否总是必须在之后运行预编译任务,然后就可以接受推送失败?我将检查目录名称的警告是否导致推送时出现空白 FOG 错误

编辑同样,在 heroku 推送的 assets:precompile 任务中调用时,asset_sync 似乎没有 ENV 变量。在推送工作后运行该任务,但它“烦人”。

仍然不适合我,最近的尝试是(根据 asset_sync github project ):

lib/tasks/asset_sync.rake。

Rake::Task['assets:precompile'].enhance do
AssetSync.sync
end

Rake::Task["assets:precompile:nondigest"].enhance do
AssetSync.sync
end

我还尝试在我的 production.rb 文件中添加行,例如:

  config.asset_sync.aws_bucket = ENV['FOG_DIRECTORY']
config.asset_sync.fog_provider = ENV['FOG_PROVIDER']

对我也不起作用。

最佳答案

asset_sync docs Labs section 下面运行

heroku labs:enable user-env-compile -a myapp

还没有作为标准进入平台!

关于ruby-on-rails - rails Assets :precompile during slug for s3 error: Fog provider and directory can't be blank when env are set,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13750690/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com