New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Works with Rails 3.2.0? #41

Closed
manuelmeurer opened this Issue Jan 22, 2012 · 40 comments

Comments

Projects
None yet
@manuelmeurer
Contributor

manuelmeurer commented Jan 22, 2012

I just upgraded to Rails 3.2.0 and asset_sync 0.2.5 and it doesn't seem to work.
I followed the upgrade instructions in the Readme and everything went fine, but when I deploy with Capistrano, the assets are not uploaded to S3.

This is my config/initializers/asset_sync.rb:

AssetSync.configure do |config|
  config.fog_provider          = 'AWS'
  config.aws_access_key_id     = AppConfig.aws[:key]
  config.aws_secret_access_key = AppConfig.aws[:secret]
  config.fog_directory         = AppConfig.aws[:bucket]

  # Increase upload performance by configuring your region
  config.fog_region = AppConfig.aws[:region]

  # Don't delete files from the store
  config.existing_remote_files = 'delete'

  # 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

and my lib/tasks/asset_sync.rake:

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

When I call AssetSync.sync from the Rails console on production after deploy, it works as expected and the assets are uploaded.

@kpfefferle

This comment has been minimized.

Show comment
Hide comment
@kpfefferle

kpfefferle Jan 23, 2012

I had a similar issue after upgrade to 3.2.0 where assets will sync and upload if I compile them locally, but do not upload on push to Heroku.

kpfefferle commented Jan 23, 2012

I had a similar issue after upgrade to 3.2.0 where assets will sync and upload if I compile them locally, but do not upload on push to Heroku.

@maioral

This comment has been minimized.

Show comment
Hide comment
@maioral

maioral Jan 23, 2012

+1 in heroku too.

maioral commented Jan 23, 2012

+1 in heroku too.

@aaronchi

This comment has been minimized.

Show comment
Hide comment
@aaronchi

aaronchi Jan 23, 2012

appears not to be running anymore under Rails 3.2/heroku :(

aaronchi commented Jan 23, 2012

appears not to be running anymore under Rails 3.2/heroku :(

@mrship

This comment has been minimized.

Show comment
Hide comment
@mrship

mrship Jan 23, 2012

I'm having the same issue on Heroku.

My workaround is to run AssetSync.sync from the heroku console after deploy.

mrship commented Jan 23, 2012

I'm having the same issue on Heroku.

My workaround is to run AssetSync.sync from the heroku console after deploy.

@subblue

This comment has been minimized.

Show comment
Hide comment
@subblue

subblue Jan 24, 2012

Same issue here. Currently getting around it by running heroku run rake assets:precompile manually after deployment to Heroku.

subblue commented Jan 24, 2012

Same issue here. Currently getting around it by running heroku run rake assets:precompile manually after deployment to Heroku.

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 25, 2012

Contributor

Damn, I thought @manuelmeurer's issue was down to not integrating capistrano. Turns out there is an issue with Rails 3.2 and Heroku. I don't fully understand what's going on here yet.

If you add Rake.application.options.trace = true in application.rb it gives us some extra rake debugging in a Rails app.

On a git push heroku it would appear that the rake assets:precompile task does not get "enhanced" correctly and subsequently not run. However running heroku run rake assets:precompile after deploy does work.

Rails 3.2 appears to be doing some more crazy stuff now to invoke rake tasks, which appear to wipe out the "enhance" of rake assets:precompile

As a work around the following appears to work for me (on Heroku at least). If you are to create the file lib/tasks/asset_sync.rake and add this task.

Rake::Task["assets:precompile:nondigest"].enhance do
  Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
  AssetSync.sync
end

You may notice this is the rake task from within the asset_sync gem but with one key difference, we are now "enhancing" the rake assets:precompile:nondigest task. We may consider making this the standard approach going forward if it works for people...

If it works for Rails 3.1.x apps too, that'll be great.

Contributor

davidjrice commented Jan 25, 2012

Damn, I thought @manuelmeurer's issue was down to not integrating capistrano. Turns out there is an issue with Rails 3.2 and Heroku. I don't fully understand what's going on here yet.

If you add Rake.application.options.trace = true in application.rb it gives us some extra rake debugging in a Rails app.

On a git push heroku it would appear that the rake assets:precompile task does not get "enhanced" correctly and subsequently not run. However running heroku run rake assets:precompile after deploy does work.

Rails 3.2 appears to be doing some more crazy stuff now to invoke rake tasks, which appear to wipe out the "enhance" of rake assets:precompile

As a work around the following appears to work for me (on Heroku at least). If you are to create the file lib/tasks/asset_sync.rake and add this task.

Rake::Task["assets:precompile:nondigest"].enhance do
  Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
  AssetSync.sync
end

You may notice this is the rake task from within the asset_sync gem but with one key difference, we are now "enhancing" the rake assets:precompile:nondigest task. We may consider making this the standard approach going forward if it works for people...

If it works for Rails 3.1.x apps too, that'll be great.

@manuelmeurer

This comment has been minimized.

Show comment
Hide comment
@manuelmeurer

manuelmeurer Jan 25, 2012

Contributor

This seems to work in both Rails 3.1.3 and 3.2.0.

Contributor

manuelmeurer commented Jan 25, 2012

This seems to work in both Rails 3.1.3 and 3.2.0.

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 25, 2012

Contributor

Great, I've created a branch and improved the default asset_sync task. If you want to get this working you can now just use the following in your Gemfile. I want to see if I can make sure it works from Rails 3.1.0 upwards if possible before releasing.

 gem 'asset_sync', :git => 'git://github.com/rumblelabs/asset_sync.git', :branch => 'rails-3-2'
Contributor

davidjrice commented Jan 25, 2012

Great, I've created a branch and improved the default asset_sync task. If you want to get this working you can now just use the following in your Gemfile. I want to see if I can make sure it works from Rails 3.1.0 upwards if possible before releasing.

 gem 'asset_sync', :git => 'git://github.com/rumblelabs/asset_sync.git', :branch => 'rails-3-2'
@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 25, 2012

Contributor

Okay, that's merged into master and released in Version 0.2.7

Contributor

davidjrice commented Jan 25, 2012

Okay, that's merged into master and released in Version 0.2.7

@davidjrice davidjrice closed this Jan 25, 2012

@manuelmeurer

This comment has been minimized.

Show comment
Hide comment
@manuelmeurer

manuelmeurer Jan 25, 2012

Contributor

Sweet, thanks!

Contributor

manuelmeurer commented Jan 25, 2012

Sweet, thanks!

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

It still does not upload assets for me in Rails 3.2. I have upgraded to 0.2.7. The rake task does work though.

It's a standard setup. I can post it and logs, but is nothing special. The files just don't get uploaded to S3 until I run the extra rake task.

amalagaura commented Jan 27, 2012

It still does not upload assets for me in Rails 3.2. I have upgraded to 0.2.7. The rake task does work though.

It's a standard setup. I can post it and logs, but is nothing special. The files just don't get uploaded to S3 until I run the extra rake task.

@iainad

This comment has been minimized.

Show comment
Hide comment
@iainad

iainad Jan 27, 2012

I have the same issue with not uploading assets (Rails 3.2/asset_sync 0.2.7). Manually calling AssetSync.sync from the console works fine, but it's not called post asset:precompile.

iainad commented Jan 27, 2012

I have the same issue with not uploading assets (Rails 3.2/asset_sync 0.2.7). Manually calling AssetSync.sync from the console works fine, but it's not called post asset:precompile.

@subblue

This comment has been minimized.

Show comment
Hide comment
@subblue

subblue Jan 27, 2012

Still having the same problem here with 0.2.7 too

subblue commented Jan 27, 2012

Still having the same problem here with 0.2.7 too

@maioral

This comment has been minimized.

Show comment
Hide comment
@maioral

maioral Jan 27, 2012

Still having the problem in 0.2.7 too.

maioral commented Jan 27, 2012

Still having the problem in 0.2.7 too.

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 27, 2012

Contributor

@leandromaioral @subblue @amalagaura @iainad if you need any further help can you create a new issue. The library definitely works with Rails 3.2 therefore it's likely it is something else.

If you have not enabled the Heroku user_env_compile feature from Heroku labs then asset_sync will not actually sync on git push heroku without running the rake task after OR by hardcoding all the config in your initializer/yml.

Contributor

davidjrice commented Jan 27, 2012

@leandromaioral @subblue @amalagaura @iainad if you need any further help can you create a new issue. The library definitely works with Rails 3.2 therefore it's likely it is something else.

If you have not enabled the Heroku user_env_compile feature from Heroku labs then asset_sync will not actually sync on git push heroku without running the rake task after OR by hardcoding all the config in your initializer/yml.

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

@davidjrice I have my keys set via AssetSync.configure in an initializer. I think the issue is that now I had to turn on: config.assets.initialize_on_precompile = false

because the precompile was failing in 3.2, but not in 3.1. In 3.1 I didn't have that command working so there was a workaround that disabled after some parts of the initialization.

On the README it states:

Will not work on heroku using ENV variables with the configuration as described below, you must hardcode all variables

However are you saying it will work with the user_env_compile feature? Or I can simply use a YML instead of the .rb initializer so the YML wil get detected?

amalagaura commented Jan 27, 2012

@davidjrice I have my keys set via AssetSync.configure in an initializer. I think the issue is that now I had to turn on: config.assets.initialize_on_precompile = false

because the precompile was failing in 3.2, but not in 3.1. In 3.1 I didn't have that command working so there was a workaround that disabled after some parts of the initialization.

On the README it states:

Will not work on heroku using ENV variables with the configuration as described below, you must hardcode all variables

However are you saying it will work with the user_env_compile feature? Or I can simply use a YML instead of the .rb initializer so the YML wil get detected?

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 27, 2012

Contributor

@amalagaura so does it work now?

yes, you can use ENV variables with the user_env_compile labs add on.
As these are now exposed to the ruby buildpack, they are instantiated when rake assets:precompile runs.

It should work with the initialize_on_precompile flag set to true or false.

Contributor

davidjrice commented Jan 27, 2012

@amalagaura so does it work now?

yes, you can use ENV variables with the user_env_compile labs add on.
As these are now exposed to the ruby buildpack, they are instantiated when rake assets:precompile runs.

It should work with the initialize_on_precompile flag set to true or false.

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

Still isn't working. First I tried with the user_env_compile by using the YML with string interpolation of the ENV variables. That didn't work, so I tried hardcoding the access keys in the YML. Also didn't work.

I added config/asset_sync.yml which I copied from the readme.. It doesn't throw any error message, just skips the upload.

Now trying the upload via rake that also breaks. This must be some other issue. It was working with the .rb initalizer via rake. Now I get
Fog provider can't be blank, Fog directory can't be blank

But my YML is exactly according to the README.

defaults: &defaults
  fog_provider: 'AWS'
  fog_directory: 'sales-system-assets'
  aws_access_key_id: 'ACCESS'
  aws_secret_access_key: 'SECRET'
  fail_silently = false

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults

amalagaura commented Jan 27, 2012

Still isn't working. First I tried with the user_env_compile by using the YML with string interpolation of the ENV variables. That didn't work, so I tried hardcoding the access keys in the YML. Also didn't work.

I added config/asset_sync.yml which I copied from the readme.. It doesn't throw any error message, just skips the upload.

Now trying the upload via rake that also breaks. This must be some other issue. It was working with the .rb initalizer via rake. Now I get
Fog provider can't be blank, Fog directory can't be blank

But my YML is exactly according to the README.

defaults: &defaults
  fog_provider: 'AWS'
  fog_directory: 'sales-system-assets'
  aws_access_key_id: 'ACCESS'
  aws_secret_access_key: 'SECRET'
  fail_silently = false

development:
  <<: *defaults

test:
  <<: *defaults

production:
  <<: *defaults
@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

So I readded my initializer, and the rake task works, but the upload on deploy still fails silently even though I have fail_silently as false. That suggests the rake enhance is not working. With YML both fail. All on Cedar stack of course.

amalagaura commented Jan 27, 2012

So I readded my initializer, and the rake task works, but the upload on deploy still fails silently even though I have fail_silently as false. That suggests the rake enhance is not working. With YML both fail. All on Cedar stack of course.

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 27, 2012

Contributor

Is config.assets.digest set to true?

Sent from my tiny Internet machine

On 27 Jan 2012, at 17:18, Ankur Sethi
reply@reply.github.com
wrote:

So I readded my initializer, and the rake task works, but the upload on deploy still fails silently even though I have fail_silently as false. That suggests the rake enhance is not working. With YML both fail. All on Cedar stack of course.


Reply to this email directly or view it on GitHub:
#41 (comment)

Contributor

davidjrice commented Jan 27, 2012

Is config.assets.digest set to true?

Sent from my tiny Internet machine

On 27 Jan 2012, at 17:18, Ankur Sethi
reply@reply.github.com
wrote:

So I readded my initializer, and the rake task works, but the upload on deploy still fails silently even though I have fail_silently as false. That suggests the rake enhance is not working. With YML both fail. All on Cedar stack of course.


Reply to this email directly or view it on GitHub:
#41 (comment)

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

Yes in config/environments/production.rb

amalagaura commented Jan 27, 2012

Yes in config/environments/production.rb

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Jan 27, 2012

Contributor

Hmm... If you can share the app with me I'll have a closer look

Sent from my tiny Internet machine

On 27 Jan 2012, at 18:31, Ankur Sethi
reply@reply.github.com
wrote:

Yes in config/environments/production.rb


Reply to this email directly or view it on GitHub:
#41 (comment)

Contributor

davidjrice commented Jan 27, 2012

Hmm... If you can share the app with me I'll have a closer look

Sent from my tiny Internet machine

On 27 Jan 2012, at 18:31, Ankur Sethi
reply@reply.github.com
wrote:

Yes in config/environments/production.rb


Reply to this email directly or view it on GitHub:
#41 (comment)

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 27, 2012

@davidjrice I sent an email to the contact address on your website

amalagaura commented Jan 27, 2012

@davidjrice I sent an email to the contact address on your website

@iainad

This comment has been minimized.

Show comment
Hide comment
@iainad

iainad Jan 27, 2012

Just fyi, here's my rake trace showing that asset_sync doesn't get called:

  * executing `deploy:assets:precompile'
  * executing "cd /webapps/site-preview/releases/20120127205114 && bundle exec rake RAILS_ENV=preview RAILS_GROUPS=assets assets:precompile"
    servers: ["site.domain.tld"]
    [site.domain.tld] executing command
*** [err :: site.domain.tld] DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:all (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:all
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:primary (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke tmp:cache:clear (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute tmp:cache:clear
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:primary
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:nondigest (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke tmp:cache:clear (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute tmp:cache:clear
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:nondigest
*** [err :: site.domain.tld] 
    command finished in 242673ms
  * executing `deploy:symlink'

I have config.assets.digest set to true as above too with rails 3.2 and asset_sync 0.2.7.

iainad commented Jan 27, 2012

Just fyi, here's my rake trace showing that asset_sync doesn't get called:

  * executing `deploy:assets:precompile'
  * executing "cd /webapps/site-preview/releases/20120127205114 && bundle exec rake RAILS_ENV=preview RAILS_GROUPS=assets assets:precompile"
    servers: ["site.domain.tld"]
    [site.domain.tld] executing command
*** [err :: site.domain.tld] DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:all (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:all
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:primary (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke tmp:cache:clear (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute tmp:cache:clear
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:primary
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] DEPRECATION WARNING: Calling set_table_name is deprecated. Please use `self.table_name = 'the_name'` instead. (called from require at /usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.15/lib/bundler/runtime.rb:68)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:precompile:nondigest (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke assets:environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke environment (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute environment
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Invoke tmp:cache:clear (first_time)
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute tmp:cache:clear
*** [err :: site.domain.tld] 
*** [err :: site.domain.tld] ** Execute assets:precompile:nondigest
*** [err :: site.domain.tld] 
    command finished in 242673ms
  * executing `deploy:symlink'

I have config.assets.digest set to true as above too with rails 3.2 and asset_sync 0.2.7.

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 31, 2012

@leandromaioral @subblue @davidjrice David has been looking at my app. So far a custom task in lib/tasks/asset_sync.rake is working to enhance the rake task.

Rake::Task["assets:precompile:nondigest"].enhance do
  Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
  AssetSync.sync
end

David didn't know why my particular Rails 3.2.1 app was different from others and needed the rake task. He said he's looking into it. This is a workaround I suppose.

@iainad Your issue is different because your explicitly run rake task is not uploading. You have RAILS_ENV=preview. Maybe that is the issue. The README says only production env works on Heroku, I don't know if it is supposed to work if you are running locally.

amalagaura commented Jan 31, 2012

@leandromaioral @subblue @davidjrice David has been looking at my app. So far a custom task in lib/tasks/asset_sync.rake is working to enhance the rake task.

Rake::Task["assets:precompile:nondigest"].enhance do
  Rake::Task["assets:environment"].invoke if Rake::Task.task_defined?("assets:environment")
  AssetSync.sync
end

David didn't know why my particular Rails 3.2.1 app was different from others and needed the rake task. He said he's looking into it. This is a workaround I suppose.

@iainad Your issue is different because your explicitly run rake task is not uploading. You have RAILS_ENV=preview. Maybe that is the issue. The README says only production env works on Heroku, I don't know if it is supposed to work if you are running locally.

@iainad

This comment has been minimized.

Show comment
Hide comment
@iainad

iainad Jan 31, 2012

@amalagaura actually I'm not using Heroku (just asset_sync on my normal rails deploy to EC2).

Anyways, adding that as a rake task to my lib/tasks dir in my app works just fine so that looks to be a sensible approach. I'd worked around it using a similar task called post precompile, but this is cleaner and easier.

So works for me too!

iainad commented Jan 31, 2012

@amalagaura actually I'm not using Heroku (just asset_sync on my normal rails deploy to EC2).

Anyways, adding that as a rake task to my lib/tasks dir in my app works just fine so that looks to be a sensible approach. I'd worked around it using a similar task called post precompile, but this is cleaner and easier.

So works for me too!

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Jan 31, 2012

@iainad Well looks to be 2 different but related issues. My issue was that the Heroku push did not upload assets. A local or heroku rake task was uploading. @davidjrice was looking at that on my app.

Your issue and the original issue by @manuelmeurer was that the assets:precompile rake tasks don't upload. So in both cases the rake task in the gem is not being picked up by the application.

amalagaura commented Jan 31, 2012

@iainad Well looks to be 2 different but related issues. My issue was that the Heroku push did not upload assets. A local or heroku rake task was uploading. @davidjrice was looking at that on my app.

Your issue and the original issue by @manuelmeurer was that the assets:precompile rake tasks don't upload. So in both cases the rake task in the gem is not being picked up by the application.

@masterkain

This comment has been minimized.

Show comment
Hide comment
@masterkain

masterkain Feb 20, 2012

Same issue here, not on Heroku but asset_sync is never called nonetheless.

masterkain commented Feb 20, 2012

Same issue here, not on Heroku but asset_sync is never called nonetheless.

@nextofsearch

This comment has been minimized.

Show comment
Hide comment
@nextofsearch

nextofsearch Feb 23, 2012

Rails 3.2.1 with cedar stack on Heroku. labs plugin installed.

@amalagaura the custom task you put on the above doesn't work for me. :(

nextofsearch commented Feb 23, 2012

Rails 3.2.1 with cedar stack on Heroku. labs plugin installed.

@amalagaura the custom task you put on the above doesn't work for me. :(

@ekampp

This comment has been minimized.

Show comment
Hide comment
@ekampp

ekampp Feb 28, 2012

It does say in the read me for asset_sync that you need to run the assets:precompile after pushing to Heroku.

So basically I run git push heroku master and when that is done I run heroku run rake assets:precompile. This will ensure that heroku picks up the fact that I would like to precompile my assets with asset_sync.

This works excellently for me.

ekampp commented Feb 28, 2012

It does say in the read me for asset_sync that you need to run the assets:precompile after pushing to Heroku.

So basically I run git push heroku master and when that is done I run heroku run rake assets:precompile. This will ensure that heroku picks up the fact that I would like to precompile my assets with asset_sync.

This works excellently for me.

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Feb 28, 2012

It's supposed to work without running an extra rake task because heroku runs the assets:precompile step as part of a deploy. After @davidjrice looked into it and added the extra code it is working on mine. But apparently that fix is not working for everyone.

amalagaura commented Feb 28, 2012

It's supposed to work without running an extra rake task because heroku runs the assets:precompile step as part of a deploy. After @davidjrice looked into it and added the extra code it is working on mine. But apparently that fix is not working for everyone.

@ekampp

This comment has been minimized.

Show comment
Hide comment
@ekampp

ekampp Feb 28, 2012

Ahh.. I see :) Well, that rake task that you referenced works awesome for me. =)

ekampp commented Feb 28, 2012

Ahh.. I see :) Well, that rake task that you referenced works awesome for me. =)

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Feb 28, 2012

Contributor

Everyone. This is a sporadic issue where Rails 3.2 is not seeing tasks registered in a Gem when run under the rake assets:precompile task. The reason it is sporadic is, in attempting to debug this it seems to happen in some projects and not others.

We're working to find a permanent solution that will make the gems enhancements to the precompile tasks visible again. Until then you can simply put the following in lib/tasks/asset_sync.rake.

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

Depending on your configuration, you may need to enhance the rake assets:precompile:nondigest

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

Running rake assets:precompile in Rails 3.2 is SLOW. AssetSync does add to that, however the majority of time is spent in Rails.

Contributor

davidjrice commented Feb 28, 2012

Everyone. This is a sporadic issue where Rails 3.2 is not seeing tasks registered in a Gem when run under the rake assets:precompile task. The reason it is sporadic is, in attempting to debug this it seems to happen in some projects and not others.

We're working to find a permanent solution that will make the gems enhancements to the precompile tasks visible again. Until then you can simply put the following in lib/tasks/asset_sync.rake.

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

Depending on your configuration, you may need to enhance the rake assets:precompile:nondigest

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

Running rake assets:precompile in Rails 3.2 is SLOW. AssetSync does add to that, however the majority of time is spent in Rails.

@seivan

This comment has been minimized.

Show comment
Hide comment
@seivan

seivan Feb 28, 2012

If that doesn't help.
Try to run bundle exec rails runner "AssetSync.sync" on the heroku server after pushing.

git push heroku master
heroku run bundle exec rails runner "AssetSync.sync"

seivan commented Feb 28, 2012

If that doesn't help.
Try to run bundle exec rails runner "AssetSync.sync" on the heroku server after pushing.

git push heroku master
heroku run bundle exec rails runner "AssetSync.sync"

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Feb 28, 2012

Contributor

@seivan that step is not required. The official solution is to define your own rake task as described above.

Ensuring that your heroku configuration variables are correct and that you have enabled the user_env_compile feature from heroku labs.

Using heroku run bundle exec rails runner "AssetSync.sync" will mean your application is deployed and the assets are not synced to your asset host. This could cause issues with assets not being available when the new version of your application comes online.

Contributor

davidjrice commented Feb 28, 2012

@seivan that step is not required. The official solution is to define your own rake task as described above.

Ensuring that your heroku configuration variables are correct and that you have enabled the user_env_compile feature from heroku labs.

Using heroku run bundle exec rails runner "AssetSync.sync" will mean your application is deployed and the assets are not synced to your asset host. This could cause issues with assets not being available when the new version of your application comes online.

@seivan

This comment has been minimized.

Show comment
Hide comment
@seivan

seivan Mar 1, 2012

@davidjrice I understand. So far defining the rake tasks with enhance does not work. Changed some javascript, pushed to Heroku. It could not find it on s3.
Ran heroku run bundle exec rails runner "AssetSync.sync" and all is good.
I have to run heroku run bundle exec rails runner "AssetSync.sync" after each deploy, even with enhanced rake tasks.

seivan commented Mar 1, 2012

@davidjrice I understand. So far defining the rake tasks with enhance does not work. Changed some javascript, pushed to Heroku. It could not find it on s3.
Ran heroku run bundle exec rails runner "AssetSync.sync" and all is good.
I have to run heroku run bundle exec rails runner "AssetSync.sync" after each deploy, even with enhanced rake tasks.

@davidjrice

This comment has been minimized.

Show comment
Hide comment
@davidjrice

davidjrice Mar 4, 2012

Contributor

Okay everyone please checkout the latest Version 0.2.12 I've made some changes to how asset_sync gets called.

I have tested with both Rails 3.1.1 and Rails 3.2. However I'd appreciate hearing back if this doesn't work for anyone. To test this:

  • Upgrade to 0.2.12 bundle update asset_sync
  • or add gem 'asset_sync', '0.2.12' to your Gemfile
  • Delete your custom lib/tasks/asset_sync.rake

I am going to close this issue, if there is anything additional that comes up because of this upgrade, please start a new issue as this one is getting quite long!

Check out my commit dfccf31 if you're interested on what was causing the issue.

Contributor

davidjrice commented Mar 4, 2012

Okay everyone please checkout the latest Version 0.2.12 I've made some changes to how asset_sync gets called.

I have tested with both Rails 3.1.1 and Rails 3.2. However I'd appreciate hearing back if this doesn't work for anyone. To test this:

  • Upgrade to 0.2.12 bundle update asset_sync
  • or add gem 'asset_sync', '0.2.12' to your Gemfile
  • Delete your custom lib/tasks/asset_sync.rake

I am going to close this issue, if there is anything additional that comes up because of this upgrade, please start a new issue as this one is getting quite long!

Check out my commit dfccf31 if you're interested on what was causing the issue.

@davidjrice davidjrice closed this Mar 4, 2012

@amalagaura

This comment has been minimized.

Show comment
Hide comment
@amalagaura

amalagaura Mar 4, 2012

I just tested and I can confirm it works on Heroku. Rails 3.2.2 with ruby 1.9.3 ( I deleted the extra rake task too)

amalagaura commented Mar 4, 2012

I just tested and I can confirm it works on Heroku. Rails 3.2.2 with ruby 1.9.3 ( I deleted the extra rake task too)

@ehoch

This comment has been minimized.

Show comment
Hide comment
@ehoch

ehoch Mar 5, 2012

Fixed for me as well! Rails 3.2.1 with ruby 1.9.2. Thanks!!

ehoch commented Mar 5, 2012

Fixed for me as well! Rails 3.2.1 with ruby 1.9.2. Thanks!!

@skwp

This comment has been minimized.

Show comment
Hide comment
@skwp

skwp Jul 31, 2013

I'm having a complete mystery issue where one of the developers on my team when he runs deploy the asset sync task is not invoked. We compared rake/cap/asset_sync/codebase versions and everything is identical. When we look at the output of his deploy, the asset sync is simply not invoked. We tried the custom rake task but still to no avail. Has anyone seen this issue recently? Asset sync 0.5.4 rails 3.2

skwp commented Jul 31, 2013

I'm having a complete mystery issue where one of the developers on my team when he runs deploy the asset sync task is not invoked. We compared rake/cap/asset_sync/codebase versions and everything is identical. When we look at the output of his deploy, the asset sync is simply not invoked. We tried the custom rake task but still to no avail. Has anyone seen this issue recently? Asset sync 0.5.4 rails 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment