Rails 4 asset pipeline generates different digest in different environments

34 views
Skip to first unread message

Sri

unread,
Sep 2, 2015, 1:31:13 AM9/2/15
to Ruby on Rails: Talk

Hello,

I am facing this weird issue. I believe the asset digests are generated based on the content of the file. However, when I deploy my application using Capistrano to staging environments and multiple boxes in production environment, I see different digests everywhere.

E.g.

In staging

walk-7c37170aabab6fdd99a9d17a303abfaf.jpg

Production

walk-0456e469fd62f3542f72164914da851f.jpg
walk-14c6d0204ad05c65f224f93e3d60deb8.jpg(older)
walk-73cce916ff11427c80512c1e69be4d4d.jpg(older)

I am not using any custom Capistrano tasks. Here is my deploy.rb for reference.

set :application, '<SNIP>'
set :deploy_user, 'ubuntu'

set :deploy_to, "/home/#{fetch(:deploy_user)}/apps/#{fetch(:application)}"
set :migrate_target,  :current
set :rails_env, "production"
set :rvm1_ruby_version, "2.1.1"
set :rvm_type, :system
set :default_shell, '/bin/bash -l'
set :pty, true 
set :ssh_options, {
forward_agent: true
}

#RVM setup

set :scm, :git
set :repo_url, '<SNIP>'
set :branch, "master"
set :log_level, :debug


set :linked_files, fetch(:linked_files,    []).push('config/database.yml','config/application.yml','config/secrets.yml')


set :linked_dirs, fetch(:linked_dirs,[]).push('log','tmp/pids','tmp/cache', 'tmp/sockets', 'vendor/bundle','public/system','public/images','public/assets')

set :bundle_binstubs, nil



after 'deploy:publishing', 'deploy:restart'
namespace :deploy do
  task :restart do
  invoke 'unicorn:restart'
end

end

What could explain this difference? Am I doing something wrong? Can I force asset digests to be created consistently?


Also posted on stackoverflow.

http://stackoverflow.com/questions/32336707/rails-4-asset-pipeline-generates-different-digest-in-different-environments

Stewart Mckinney

unread,
Sep 2, 2015, 10:06:34 AM9/2/15
to rubyonra...@googlegroups.com
Why is this an issue? Typically speaking this should be transparent at the application layer all the time. If you need another app or service to be able to access images on your app you should expose that through an API.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/0d5a5fc9-8cdc-453e-abc0-957cdf20446b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stewart Mckinney

unread,
Sep 2, 2015, 10:18:21 AM9/2/15
to rubyonra...@googlegroups.com
Ahhhhhhhhhh.

Are you using S3 for image hosting and see broken links on dev because it uses a copy ( shallow or otherwise ) of another environments data?

Frederick Cheung

unread,
Sep 2, 2015, 11:19:10 AM9/2/15
to Ruby on Rails: Talk


On Wednesday, September 2, 2015 at 6:31:13 AM UTC+1, Sri wrote:


What could explain this difference? Am I doing something wrong? Can I force asset digests to be created consistently?


Are the files definitely identical?

Fred

Walter Lee Davis

unread,
Sep 2, 2015, 11:38:31 AM9/2/15
to rubyonra...@googlegroups.com
Does the asset pipeline compilation use the rake secret, by any chance?

Walter


Fred

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.

gerbdla

unread,
Sep 2, 2015, 1:26:04 PM9/2/15
to Ruby on Rails: Talk
I would imagine that it is because the secret key is different in each environment. 
Reply all
Reply to author
Forward
0 new messages