rails assets:在slug期间为s3错误预编译:当设置env时,雾提供程序和目录不能为空

twi*_*tom 2 assets ruby-on-rails heroku amazon-s3

我决定通过S3提供rails资产; heroku有很棒的教程如何做到这一点.该网站现在从我的亚马逊桶提供资产,但我不确定为什么我必须手动运行heroku run rake assets:precompile一个git push heroku master运行a rake assets:precompile.

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

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
Run Code Online (Sandbox Code Playgroud)

我确实设置了雾提供程序和目录:heroku config:add FOG_DIRECTORY=XXX FOD_PROVIDER=AWS并且调用heroku config --app确认了这个...所以我没有得到这些错误.

资产没有显示在我的桶中,所以我跑了: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
Run Code Online (Sandbox Code Playgroud)

我是否总是必须在之后运行预编译任务并且只是对推送失败感到满意?我将检查目录名称的警告是否导致推送时出现空白FOG错误

编辑 再次在资产中调用asset_sync似乎没有ENV变量:heroku push的预编译任务.推送后运行该任务,但它"烦人".

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

LIB /任务/ asset_sync.rake.

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

Rake::Task["assets:precompile:nondigest"].enhance do
  AssetSync.sync
end
Run Code Online (Sandbox Code Playgroud)

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

  config.asset_sync.aws_bucket = ENV['FOG_DIRECTORY']
  config.asset_sync.fog_provider = ENV['FOG_PROVIDER']
Run Code Online (Sandbox Code Playgroud)

对我来说也没用.

twi*_*tom 10

asset_sync docs Labs部分下面运行

heroku labs:enable user-env-compile -a myapp
Run Code Online (Sandbox Code Playgroud)

还没有成为标准的平台!

  • 这已经完全过时了.Heroku返回:没有这样的功能:user-env-compile (2认同)