Assets not loading with Rails 3.1.1 #3291

Closed
conradwt opened this Issue Oct 11, 2011 · 11 comments

Projects

None yet

2 participants

I just upgraded from 3.1.0 to 3.1.1 and I noticed the assets (i.e. images, javascripts, and stylesheets) are not properly loaded when running production locally in Mac OS 10.7.1:

Gemfile:

source 'http://rubygems.org'
source 'http://gems.github.com'

gem "rails", "> 3.1.1"
gem "pg", "
> 0.11.0"
gem "execjs", "> 1.2.6"
gem 'jquery-rails'
gem "therubyracer", "
> 0.9.4"
gem 'formtastic', '~> 1.1.0'

Gems used only for assets and not required

in production environments by default.

group :assets do
gem 'coffee-rails', "> 3.1.1"
gem 'sass-rails', "
> 3.1.4"
gem "uglifier", "~> 1.0.3"

gem 'closure-compiler'

end

group :test do

Pretty printed test output

gem 'turn', :require => false
end

Capfile:

load 'deploy' if respond_to?(:namespace) # cap2 differentiator

Uncomment if you are using Rails' asset pipeline

load 'deploy/assets'

Dir['vendor/gems//recipes/.rb','vendor/plugins//recipes/.rb'].each { |plugin| load(plugin) }

load 'config/deploy' # remove this line to skip loading any of the default tasks
load 'deploy/assets'

Next, I noticed the 'cap deploy' started failing when attempting to deploy to staging. Thus, I'm seeing the following error message:

$ cap -V
Capistrano v2.9.0

Message:

*** [err :: smartn.me] /usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /home/smartn/smartn.me/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: smartn.me]
*** [err :: smartn.me] rake aborted!

BTW, I have the following set with the production.rb:

config.assets.compile = true
config.assets.digest = true

Thus, I'm not sure why the 'assets:precompile:nondigest' when I have specified a digest to be enabled when deploying to a production test environment.

Owner

you should have config.serve_static_assets = true in production.rb if you want run the app locally in production mode

This resolves the issue of trying to run a production environment locally but deploying to staging is more of a concern at this time.

Owner

what's your problem deploying to staging?

$ cap deploy

...

*** [err :: smartn.me] /usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /home/smartn/smartn.me/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: smartn.me]
*** [err :: smartn.me] rake aborted!

This task needs to publicly documented.

Owner

what's the output of "bundle exec rake assets:precompile --trace" (running it on staging server)?

Guillermo Iguaran

On Wednesday, October 12, 2011 at 1:41 AM, Conrad Taylor wrote:

Message:

*** [err :: smartn.me (http://smartn.me)] /usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /home/smartn/smartn.me/shared/bundle/ruby/1.9.1/bin/rake (http://smartn.me/shared/bundle/ruby/1.9.1/bin/rake) assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets
*** [err :: smartn.me (http://smartn.me)]
*** [err :: smartn.me (http://smartn.me)] rake aborted!

This task needs to publicly documented.

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

Owner

this is failing also in 1.9.2-p290?

bundle exec rake assets:precompile fails running locally?

$ ruby -v
ruby 1.9.2p312 (2011-08-11 revision 32926) [x86_64-darwin11.1.0]

$ bundle exec rake assets:precompile

completes without error

The following command actually completes without errors on the production server:

$ bundle exec rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

However, capistrano executes the following command when dealing with the no digest and fails in production:

$ /usr/local/rvm/rubies/ruby-1.9.2-head/bin/ruby /home/smartn/smartn.me/shared/bundle/ruby/1.9.1/bin/rake assets:precompile:nondigest RAILS_ENV=production RAILS_GROUPS=assets

For now, I have disabled the Capistrano deploy recipe by doing the following:

load 'deploy/assets'

Thus, my deploy goes something like this:

Locally, I do the following:

$ bundle exec rake assets:precompile RAILS_ENV=production RAILS_GROUPS=assets
$ cap deploy
$ rsync -avz public/assets/ user@host:/parent_directory_of_assets/assets/

I may integrate this into my Capistrano recipe at some point depending on the forthcoming status of this issue.

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