Skip to content
This repository

Precompiling raises nil value for config.assets_dir #86

Closed
dewski opened this Issue January 06, 2012 · 18 comments
Garrett Bjerkhoel

After having some major issues over the past few weeks trying to get this to compile on Heroku, I ran into a new issue.

Previously #85, sprockets/270, and other rails related issues were the cause of those.

Now during precompiling it will error out saying can't convert nil into String which points to ActionView::AssetPaths on line 36. I inserted a puts config.assets_dir which returns nil. I have a feeling sass-rails isn't passing in the correct config, but I am still investigating myself.

module ActionView
  class AssetPaths #:nodoc:

    # ...

    # Return the filesystem path for the source
    def compute_source_path(source, dir, ext)
      source = rewrite_extension(source, dir, ext) if ext
      puts config.assets_dir # => nil
      File.join(config.assets_dir, dir, source)
    end

    # ...
  end
end

I have attached the tracelog and my bundle list output to help.

The output of the rake task:

dewski ~/work/rails/site (master) 
$ RAILS_ENV=development bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/dewski/.rvm/rubies/ruby-1.9.2-p290/bin/ruby /Users/dewski/.rvm/gems/ruby-1.9.2-p290/bin/rake assets:precompile:all RAILS_ENV=development RAILS_GROUPS=assets --trace
** Invoke assets:precompile:all (first_time)
** Execute assets:precompile:all
** Invoke assets:precompile:primary (first_time)
** Invoke assets:environment (first_time)
** Execute assets:environment
** Invoke tmp:cache:clear (first_time)
** Execute tmp:cache:clear
** Execute assets:precompile:primary
rake aborted!
can't convert nil into String
  (in /Users/dewski/work/rails/site/app/assets/stylesheets/application.css.scss)
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/action_view/asset_paths.rb:37:in `join'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/action_view/asset_paths.rb:37:in `compute_source_path'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sass-rails-3.2.3/lib/sass/rails/template_handlers.rb:23:in `source_path'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sass-rails-3.2.3/lib/sass/rails/template_handlers.rb:84:in `sass_options'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sass-rails-3.2.3/lib/sass/rails/template_handlers.rb:106:in `evaluate'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/context.rb:177:in `block in evaluate'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/context.rb:174:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/context.rb:174:in `evaluate'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/processed_asset.rb:12:in `initialize'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `new'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:241:in `block in build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:262:in `circular_call_protection'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:240:in `build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `new'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:244:in `build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:89:in `block in build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/caching.rb:19:in `cache_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:88:in `build_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:163:in `find_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/index.rb:56:in `find_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/environment.rb:74:in `find_asset'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/static_compiler.rb:20:in `block in compile'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:212:in `block in each_logical_path'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:200:in `block (2 levels) in each_file'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:190:in `each_entry'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:198:in `block in each_file'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:197:in `each_file'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/sprockets-2.1.2/lib/sprockets/base.rb:210:in `each_logical_path'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/static_compiler.rb:18:in `compile'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:52:in `internal_precompile'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:66:in `block (3 levels) in <top (required)>'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dewski/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dewski/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile:primary
rake aborted!
Command failed with status (1): [/Users/dewski/.rvm/rubies/ruby-1.9.2-p290/...]
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/actionpack-3.2.0.rc2/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/dewski/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `load'
/Users/dewski/.rvm/gems/ruby-1.9.2-p290/bin/rake:19:in `<main>'
Tasks: TOP => assets:precompile

Bundle list:

dewski ~/work/rails/site (master) 
$ bundle list
Gems included by the bundle:
  * actionmailer (3.2.0.rc2)
  * actionpack (3.2.0.rc2)
  * activemodel (3.2.0.rc2)
  * activerecord (3.2.0.rc2)
  * activeresource (3.2.0.rc2)
  * activesupport (3.2.0.rc2)
  * addressable (2.2.6)
  * airbrake (3.0.3)
  * arel (3.0.0.rc1)
  * aws-s3 (0.6.2)
  * bcrypt-ruby (3.0.1)
  * bkwld-paper_trail (2.3.3)
  * bson (1.3.1)
  * bson_ext (1.3.1)
  * builder (3.0.0)
  * bundler (1.1.rc.6)
  * cancan (1.6.5)
  * capistrano (2.9.0)
  * capistrano-ext (1.2.1)
  * capistrano_colors (0.5.5)
  * chunky_png (1.2.5)
  * client_side_validations (3.1.0)
  * cocaine (0.2.1)
  * coffee-rails (3.2.1)
  * coffee-script (2.2.0)
  * coffee-script-source (1.2.0)
  * compass (0.12.alpha.4)
  * crack (0.3.1)
  * dalli (1.1.4)
  * devise (1.4.7)
  * differ (0.1.2)
  * erubis (2.7.0)
  * escape (0.0.4)
  * execjs (1.2.13)
  * flash_cookie_session (1.1.0)
  * formtastic (2.0.0.rc3)
  * fssm (0.2.8.1)
  * garb (0.9.1)
  * haml (3.1.4)
  * haml-rails (0.3.4)
  * hashie (1.2.0)
  * heroku (2.17.0)
  * highline (1.6.9)
  * hike (1.2.1)
  * hipchat (0.4.1)
  * httparty (0.8.1)
  * i18n (0.6.0)
  * journey (1.0.0.rc4)
  * jquery-rails (2.0.0)
  * json (1.6.4)
  * kaminari (0.12.4)
  * kgio (2.7.0)
  * kss (0.1.3)
  * kss-rails (1.0 a9b953d)
  * launchy (2.0.5)
  * mail (2.3.0)
  * mail_view (1.0.1 a99c2fc)
  * mime-types (1.17.2)
  * mongo (1.3.1)
  * mongoid (2.4.0)
  * multi_json (1.0.4)
  * multi_xml (0.4.1)
  * mysql2 (0.3.11)
  * net-scp (1.0.4)
  * net-sftp (2.0.5)
  * net-ssh (2.2.2)
  * net-ssh-gateway (1.1.0)
  * nokogiri (1.5.0)
  * orm_adapter (0.0.5)
  * paperclip (2.4.5)
  * paperclip-meta (0.2)
  * pg (0.12.2)
  * polyglot (0.3.3)
  * pr_geohash (1.0.0)
  * producer (0.1.0 02555d4)
  * rack (1.4.0)
  * rack-cache (1.1)
  * rack-protection (1.2.0)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.0.rc2)
  * rails-footnotes (3.7.5)
  * railties (3.2.0.rc2)
  * raindrops (0.8.0)
  * rake (0.9.2.2)
  * rash (0.3.2)
  * rdiscount (1.6.8)
  * rdoc (3.12)
  * redis (2.2.2)
  * redis-namespace (1.0.3)
  * resque (1.19.0 af5a9a8)
  * rest-client (1.6.7)
  * rsolr (1.0.6)
  * rubyzip (0.9.5)
  * sass (3.1.12)
  * sass-rails (3.2.3)
  * sinatra (1.3.2)
  * sprockets (2.1.2)
  * sunspot (1.3.0)
  * sunspot_rails (1.3.0)
  * sunspot_solr (1.3.0)
  * term-ansicolor (1.0.7)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * tzinfo (0.3.31)
  * uglifier (1.2.1)
  * unicorn (4.1.1)
  * vegas (0.1.8)
  * warden (1.0.6)
  * xml-simple (1.1.1)
  * zencoder (2.4.0)
John Maxwell

I'm seeing the same issue attempting to precompile assets. Here's my bundle:

Gems included by the bundle:
  * Ascii85 (1.0.1)
  * actionmailer (3.2.0.rc2)
  * actionpack (3.2.0.rc2)
  * activeadmin (0.3.4)
  * activemodel (3.2.0.rc2)
  * activerecord (3.2.0.rc2)
  * activeresource (3.2.0.rc2)
  * activesupport (3.2.0.rc2)
  * addressable (2.2.6)
  * ansi (1.4.0)
  * arel (3.0.0.rc1)
  * bcrypt-ruby (3.0.1)
  * bootstrap-sass (1.4.3)
  * builder (3.0.0)
  * bundler (1.1.rc.7)
  * coffee-rails (3.2.0)
  * coffee-script (2.2.0)
  * coffee-script-source (1.2.0)
  * devise (1.5.3)
  * diff-lcs (1.1.3)
  * erubis (2.7.0)
  * execjs (1.2.13)
  * factory_girl (2.1.0)
  * factory_girl_rails (1.2.0)
  * faraday (0.7.5)
  * faraday-stack (0.1.3)
  * fastercsv (1.5.4)
  * formtastic (1.2.4)
  * haml (3.1.4)
  * has_scope (0.5.1)
  * hike (1.2.1)
  * i18n (0.6.0)
  * inherited_resources (1.2.2)
  * journey (1.0.0.rc4)
  * jquery-rails (1.0.16)
  * json (1.6.4)
  * kaminari (0.13.0)
  * kgio (2.6.0)
  * mail (2.3.0)
  * meta_search (1.1.1 21e9886)
  * mime-types (1.17.2)
  * multi_json (1.0.4)
  * multipart-post (1.1.4)
  * nokogiri (1.5.0)
  * orm_adapter (0.0.5)
  * pdf-reader (1.0.0.rc1)
  * polyamorous (0.5.0)
  * polyglot (0.3.3)
  * rack (1.4.0)
  * rack-cache (1.1)
  * rack-ssl (1.3.2)
  * rack-test (0.6.1)
  * rails (3.2.0.rc2)
  * railties (3.2.0.rc2)
  * raindrops (0.8.0)
  * rake (0.9.2.2)
  * rdoc (3.12)
  * responders (0.6.4)
  * rspec (2.7.0)
  * rspec-core (2.7.1)
  * rspec-expectations (2.7.0)
  * rspec-mocks (2.7.0)
  * rspec-rails (2.7.0)
  * ruby-rc4 (0.1.3)
  * sass (3.1.12)
  * sass-rails (3.2.3)
  * sprockets (2.1.2)
  * sqlite3 (1.3.5)
  * thor (0.14.6)
  * tilt (1.3.3)
  * treetop (1.4.10)
  * turn (0.8.3)
  * tzinfo (0.3.31)
  * uglifier (1.0.4)
  * unicorn (4.1.1)
  * warden (1.1.0)
John Maxwell

In my case, the problem seemed to stem from having config.assets.initialize_on_precompile = false in application.rb, which I added when I was having problems deploying to Heroku.

From http://guides.rubyonrails.org/asset_pipeline.html:

For faster asset precompiles, you can partially load your application by setting config.assets.initialize_on_precompile to false in config/application.rb, though in that case templates cannot see application objects or methods. Heroku requires this to be false.

Turadg Aleahmad

Same here. config.assets_dir is nil and config.assets.initialize_on_precompile = false.

bootstrap-sass (1.4.3)
  sass-rails (~> 3.1)
sass (3.1.12)
sass-rails (3.2.3)

Any work-arounds?

Joe Ellis

I'm also seeing a similar error, is this a bug regression by chance?

Bill Leeper

My work around, and it's not a great one, but this is what it's like on the edge right.

In the production.rb

config.assets.initialize_on_precompile = true

Then before pushing code run:

rake assets:precompile

This will compile all your assets. Add them to your local git repository, but do not push them to your remotes.

Then deploy to heroku

git push heroku  --force

With the assets in the repository, heroku won't try and compile them. The --force is needed for subsequent pushes because we are going to remove the commit with the assets before pushing again.

Now rollback your local repository

git reset --hard HEAD^

This will remove the assets you compiled and pushed to heroku so they don't mess up your development environment and clog up your remote with artifacts.

You will need to precompile and add to the repository every time you push to heroku. Make sure to use the --force or you will get an error.

danigb

I have the same issue and I've fixed setting the initialize when precompile to true (but, in theory, I don't need it). Is this a bug or a feature? ;)

I don't use heroku and I can reproduce the problem at dev machine. Using sass-rails 3.2.3

Matt Powell

This seems to work with Heroku:

# Enable the asset pipeline
config.assets.enabled = true
config.assets.initialize_on_precompile = false
config.action_controller.assets_dir = "#{File.dirname(File.dirname(__FILE__))}/public"
Turadg Aleahmad

indeed it does.

thanks @fauxparse!

update: this work-around causes this error in rails_admin:
Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError: rails_admin/rails_admin.css isn't precompiled

Matt Powell

Disclaimer: your observed value of "working" may differ from mine ;)

Bill Leeper

@turadg do you have something like this in your application.rb or production.rb

config.assets.precompile += %w( rails_admin/rails_admin.css )

If you are explicitly including a css or js file besides application.css and application.js then you need to list all the js and css assets you wish to be compiled in a statement like above. I had the problem in this thread, but I also don't have any extra css or js, so maybe those don't work with this workaround. If that's the case you can try what I noted above (lots more work) it may work for you.

Matt Powell

Yes, my guess is that those kinds of things don't happen when initialize_on_precompile is set to false, which I only need to do because mongo_mapper connects on initialisation (actually, I should be filing an issue about that over there).

aaronchi

fauxparse's workaround works for me but confirmed failing with initialize_on_precompile = false

Turadg Aleahmad

@wleeper that worked perfectly, thanks.

Kevin Merritt

@wleeper Thanks for providing the solution to my problem. To successfully deploy to Heroku, my config looked like this:

production.rb

config.assets.precompile += %w( modernizr.js rails_admin/rails_admin.js rails_admin/rails_admin.css )

application.rb

config.assets.enabled = true

config.assets.initialize_on_precompile = false
Abram Bailey

Thanks everyone. This post saved me.

Chris Eppstein
Collaborator

So do we need to update our README? Can I close this?

Bill Leeper

I am not seeing this problem with Rails 3.2.2 and associated libraries. Not sure which one fixed it.

Francesco Rodríguez

Closing here. If the problem persists, please I'll re-open it. Thanks!

Francesco Rodríguez frodsan closed this April 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.