karlfreeman/middleman-sync

Asset_Sync problem with latest release of Middleman (3.0.12)

Closed this issue · 8 comments

Upon middleman build with the following config:

activate :sync do |sync|
  sync.fog_provider = 'AWS' 
  sync.fog_directory = ENV['BUCKET_NAME'] 
  sync.fog_region = 'us-east-1'
  sync.aws_access_key_id = ENV['AWS_ACCESS_KEY'] 
  sync.aws_secret_access_key = ENV['AWS_SECRET_KEY']
  sync.existing_remote_files = 'delete'
  sync.gzip_compression = true 
  sync.after_build = true
end

using latest middleman release (3.0.12) and latest middleman_sync, the follow error occurs:

$ middleman build
/Users/david/.rvm/gems/ruby-1.9.3-p392/gems/asset_sync-0.5.4/lib/asset_sync/config.rb:99:in `yml_path': undefined method `root' for Rails:Module (NoMethodError)

Full trace here: https://gist.github.com/dpfranklin/5052057

Sorry for the delay in getting on this. Will look into it today.

👍 I'm having the same problem

Reverting back to 3.0.9 actually helps

gem "middleman", "3.0.9"
gem "middleman-sync", "3.0.9"

+1
Note just locking the middleman-sync version to 3.0.9 doesn't fix it.

This appears have been made an issue by this commit to AssetSync:

AssetSync/asset_sync@06af52e

The change is to lib/asset_sync/config.rb:

def yml
  @yml ||= YAML.load(ERB.new(IO.read(yml_path)).result)[Rails.env] rescue nil || {}
end

to:

def yml
  begin
    @yml ||= YAML.load(ERB.new(IO.read(yml_path)).result)[Rails.env] rescue nil || {}
  rescue Psych::SyntaxError
    @yml = {}
  end
end

Has this been silently failing all along because this fails?

def yml_path
  Rails.root.join("config", "asset_sync.yml").to_s
end

Thanks for investigating @dpfranklin.

So @dpfranklin's is bang on. Even more bang on is @2a6U37Nn's pull request to asset_sync. I'd advise for now to use gem 'asset_sync', :git => 'git://github.com/2a6U37Nn/asset_sync.git in your Gemfile which should solve the problem till it 'possibly' gets merged in asset_sync.

Roll on #16

Is this still the right way to fix this? I can't seem to get this to work.