2

My asset_sync gem does not upload to s3 when I precompile assets

asset_sync.rb

if defined?(AssetSync)
  AssetSync.configure do |config|
    config.fog_provider = 'AWS'
    config.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID']
    config.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
    # To use AWS reduced redundancy storage.
    # config.aws_reduced_redundancy = true
    config.fog_directory = ENV['FOG_DIRECTORY']

    # Invalidate a file on a cdn after uploading files
    # config.cdn_distribution_id = "12345"
    # config.invalidate = ['file1.js']

    # Increase upload performance by configuring your region
    config.fog_region = 'ap-southeast-2'
    #
    # Don't delete files from the store
    # config.existing_remote_files = "keep"
    #
    # Automatically replace files with their equivalent gzip compressed version
    # config.gzip_compression = true
    #
    # Use the Rails generated 'manifest.yml' file to produce the list of files to
    # upload instead of searching the assets directory.
    # config.manifest = true
    #
    # Fail silently.  Useful for environments such as Heroku
    # config.fail_silently = true
  end
end

production.rb

  config.assets.enabled = true
  config.assets.digest = true
  config.action_controller.asset_host = "//#{ENV['FOG_DIRECTORY']}.s3.amazonaws.com"
  config.assets.initialize_on_precompile = true

application.rb

    config.assets.enabled = true
    config.assets.digest = true

When I precompile, I'm not even getting any message to show it is uploading.

Is there a reason why this is happening?

Passionate Engineer
  • 10,034
  • 26
  • 96
  • 168
  • 1
    Did you manage to solve this? I'm having the same problem now – Dave Feb 08 '14 at 11:54
  • There are valid use cases, but as an update, heroku strongly discourages this approach anymore: https://devcenter.heroku.com/articles/please-do-not-use-asset-sync –  Mar 28 '16 at 22:51

2 Answers2

1

may be you have:

group :assets do
  gem 'asset_sync'
end

you should put that gem out from that group

0

I know this issue is old... but I just inherited a Heroku app and am reading how to asset_sync with Heroku and came across this, which states ENV variables are not available when compiling assets on Heroku.

  • 1
    Link itself can't be an answer as it can be relocated or deleted. Please add some more details, it may be quotes from the link with explanation – Anna Oct 28 '19 at 21:50