Rails 4 asset pipeline generates different digest in different environments

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

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.

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?

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

Are the files definitely identical?

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

Are the files definitely identical?

Does the asset pipeline compilation use the rake secret, by any chance?

Walter

I would imagine that it is because the secret key is different in each environment.