Besi
Besi

Reputation: 22959

Capistrano: Assets not compiled when explicitly invoking `deploy:assets:precompile`

I can compile my assets in my Rails 4.1 project locally like so:

$ RAILS_ENV=staging bin/rake assets:precompile

I, [2015-03-26T17:23:21.632726 #26321]  INFO -- : Writing /MyProject/public/assets/active_admin-a46314b7dc1a06e662695c2093e33d96.js
I, [2015-03-26T17:23:21.748271 #26321]  INFO -- : Writing /MyProject/public/assets/application-adc2c7c08b35fae05d8bfc73d1696dea.js
I, [2015-03-26T17:23:21.833131 #26321]  INFO -- : Writing /MyProject/public/assets/active_admin-36d00173ec2474695cd54a330636bac9.css
I, [2015-03-26T17:23:21.851637 #26321]  INFO -- : Writing /MyProject/public/assets/application-0930e157132302bc8b8666143a832af2.css
I, [2015-03-26T17:23:21.861676 #26321]  INFO -- : Writing /MyProject/public/assets/debug-aeffd81aa2ee2b35a0d779b9335c9749.css

Also on the server directly I can create the assets using rake:

user@server$ RAILS_ENV=staging bundle exec rake assets:precompile

I, [2015-03-26T17:40:11.761707 #30743]  INFO -- : Writing /var/www/my_project/releases/20150326161842/public/assets/active_admin-a46314b7dc1a06e662695c2093e33d96.js
I, [2015-03-26T17:40:11.806881 #30743]  INFO -- : Writing /var/www/my_project/releases/20150326161842/public/assets/application-adc2c7c08b35fae05d8bfc73d1696dea.js
I, [2015-03-26T17:40:11.847215 #30743]  INFO -- : Writing /var/www/my_project/releases/20150326161842/public/assets/active_admin-36d00173ec2474695cd54a330636bac9.css

However, when I want to do the same on the remote server then no assets are created.

This is the :debug output when I run the command through capistrano:

$ cap staging deploy:assets:precompile -t

** Invoke staging (first_time)
** Execute staging
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke rbenv:validate (first_time)
** Execute rbenv:validate
DEBUG [92cdd4bf] Running /usr/bin/env [ -d ~/.rbenv/versions/2.1.2 ] as [email protected]
DEBUG [92cdd4bf] Command: [ -d ~/.rbenv/versions/2.1.2 ]
DEBUG [92cdd4bf] Finished in 0.421 seconds with exit status 0 (successful).
** Invoke rbenv:map_bins (first_time)
** Execute rbenv:map_bins
** Invoke bundler:map_bins (first_time)
** Execute bundler:map_bins
** Invoke deploy:set_rails_env (first_time)
** Execute deploy:set_rails_env
** Invoke deploy:set_rails_env 
** Invoke deploy:assets:precompile (first_time)
** Execute deploy:assets:precompile

My Capfile contains the require 'capistrano/rails/assets' through require 'capistrano/rails'.

My staging.rb contains the following directives:

# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = false
config.assets.digest = true

Why does Capistrano not generate the assets?

Upvotes: 0

Views: 5447

Answers (1)

Maxim
Maxim

Reputation: 9981

From here:

set :assets_roles, [:web, :app]            # Defaults to [:web]

I think your server doesn't have web role (or you assign app role). So, try to specify assets_roles variable as described above or change role of your server.

Upvotes: 12

Related Questions