塞S3的错误时precompile:轨资产雾提供商和目录不能为空时,ENV设置提供商、为空、错误、资产

2023-09-11 08:36:14 作者:||丶至尊↘少年﹌

我决定通过S3服务轨资产; Heroku的对如何做到这一点伟大的教程。该网站现在从我的亚马逊水桶服务资产,但我不确定为什么我不得不手动运行的Heroku运行耙资产:precompile 之后混帐推Heroku的主它运行一个耙资产:precompile

I decided to serve rails assets via S3; heroku has great tutorials on how to do this. The site is now serving assets from my amazon bucket but I'm unsure why I had to manually run heroku run rake assets:precompile after a git push heroku master which runs a rake assets:precompile.

运行混帐推Heroku的主人后资产哪里都不在我的水桶,并为precompile东西的产量为:

After running the git push heroku master the assets where not in my bucket and the output for the precompile stuff was:

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

我没设置的雾供应商和目录有: Heroku的配置:添加FOG_DIRECTORY = XXX FOD_PROVIDER = AWS 并调用Heroku的配置--app证实了这一点,所以,我不要让这些错误。

I did set the fog provider and directory with: heroku config:add FOG_DIRECTORY=XXX FOD_PROVIDER=AWS and calling heroku config --app confirms this...so I don't get those errors.

该资产并没有在我的水桶出现,所以我跑了:的Heroku运行耙资产:precompile 和警告一切工作:

The assets didn't show up in my bucket so I ran: heroku run rake assets:precompile and everything worked with a warning:

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

我会总是有后运行precompile的任务,仅仅是没关系的推失败?我查一下,看看目录名的警告导致推送的空白FOG错误

Will I always have to run the precompile task after and just be okay with the push failure? I'll check to see if the Warning of the directory name is causing the blank FOG errors on push

修改 再次asset_sync,则不会出现在资产被称为具有ENV变量:Heroku的推precompile任务。跑步推后该任务的作品,但它是烦人。

EDIT Again asset_sync doesn't appear to have ENV variables when called in the assets:precompile task of the heroku push. Running that task after push works but it 'annoying'.

仍然没有工作对我来说,最新的尝试是(每 asset_sync github上项目):

Still not working for me, latest attempt was (per asset_sync github project):

的lib /任务/ asset_sync.rake。

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文件,如:

I also attempted adding lines to my production.rb file such as:

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

对我也没有工作。

Didn't work for me either.

推荐答案

从下方运行 asset_sync文档实验室部分

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

并没有作出它的方式进入该平台作为标准呢!

Hasn't made it's way into the platform as standard yet!