fuzzybassoon
fuzzybassoon

Reputation: 53

Running 'rake assets:precompile' generates error: '`@application.css' is not allowed as an instance variable name'

I'm working on a Rails 3.2 app, and I'm trying to test precompiling my assets for when I move my app into production. The app runs fine in development, but when I run:

bundle exec rake assets:precompile

I get the following error:

rake aborted!
`@application.css' is not allowed as an instance variable name

I've searched my code, and there are no references to application.css, except of course the file of that name (and in an occasional comment).

I've also tried setting config.assets.compile = true in production mode, but that fails as well (the app server starts fine, but in production.log there are no errors, I just see the request, and Rails rendering a response, but doesn't finish).

Thanks for any help.

Here's a full trace when I run bundle exec rake assets:precompile:

$ bundle exec rake assets:precompile --trace
** Invoke assets:precompile (first_time)
** Execute assets:precompile
/Users/alb64/.rbenv/versions/1.9.2-p320/bin/ruby /Users/alb64/.rbenv/versions/1.9.2-p320/bin/rake assets:precompile:all RAILS_ENV=production 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 environment (first_time)
** Execute environment
rake aborted!
`@application.css' is not allowed as an instance variable name
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:244:in `instance_variable_set'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:244:in `block in init_with'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:244:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:244:in `init_with'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:229:in `revive'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:183:in `visit_Psych_Nodes_Mapping'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/visitor.rb:7:in `accept'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/visitors/to_ruby.rb:16:in `accept'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych/nodes/node.rb:25:in `to_ruby'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych.rb:107:in `load'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/psych.rb:205:in `load_file'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/railtie.rb:42:in `block in <class:Railtie>'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `instance_exec'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/initializable.rb:30:in `run'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/initializable.rb:55:in `block in run_initializers'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/initializable.rb:54:in `run_initializers'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/application.rb:136:in `initialize!'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/railtie/configurable.rb:30:in `method_missing'
/Users/alb64/code/stc/reservations/config/environment.rb:6:in `<top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `block in require'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:236:in `load_dependency'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/activesupport-3.2.0/lib/active_support/dependencies.rb:251:in `require'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/application.rb:103:in `require_environment!'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/railties-3.2.0/lib/rails/application.rb:292:in `block (2 levels) in initialize_tasks'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/assets.rake:89:in `block (2 levels) in <top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:176:in `block in invoke_prerequisites'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:174:in `invoke_prerequisites'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:157:in `block in invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/assets.rake:56:in `block (3 levels) in <top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/bin/rake:23:in `load'
/Users/alb64/.rbenv/versions/1.9.2-p320/bin/rake:23:in `<main>'
Tasks: TOP => environment
rake aborted!
Command failed with status (1): [/Users/alb64/.rbenv/versions/1.9.2-p320/bi...]
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:53:in `block in create_shell_runner'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `call'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:45:in `sh'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `sh'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils.rb:80:in `ruby'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/file_utils_ext.rb:39:in `ruby'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/assets.rake:9:in `ruby_rake_task'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/assets.rake:17:in `invoke_or_reboot_rake_task'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/actionpack-3.2.0/lib/sprockets/assets.rake:25:in `block (2 levels) in <top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `call'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:205:in `block in execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:200:in `execute'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:158:in `block in invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/1.9.1/monitor.rb:201:in `mon_synchronize'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:151:in `invoke_with_call_chain'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/task.rb:144:in `invoke'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:116:in `invoke_task'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block (2 levels) in top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `each'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:94:in `block in top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:88:in `top_level'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:66:in `block in run'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:133:in `standard_exception_handling'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/lib/rake/application.rb:63:in `run'
/Users/alb64/.rbenv/versions/1.9.2-p320/lib/ruby/gems/1.9.1/gems/rake-0.9.2.2/bin/rake:33:in `<top (required)>'
/Users/alb64/.rbenv/versions/1.9.2-p320/bin/rake:23:in `load'
/Users/alb64/.rbenv/versions/1.9.2-p320/bin/rake:23:in `<main>'
Tasks: TOP => assets:precompile

Edit:

Here's config/environment.rb:

# Load the rails application
require File.expand_path('../application', __FILE__)
require 'rails_extensions'

# Initialize the rails application
Reservations::Application.initialize!

And here's config/environments/production.rb:

Reservations::Application.configure do # Settings specified here will take precedence over those in config/application.rb

  # The production environment is meant for finished, "live" apps.
  # Code is not reloaded between requests
  config.cache_classes = true

  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true

  # Specifies the header that your server uses for sending files
  config.action_dispatch.x_sendfile_header = "X-Sendfile"

  # For nginx:
  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'

  # If you have no front-end server that supports something like X-Sendfile,
  # just comment this out and Rails will serve the files

  # See everything in the log (default is :info)
  # config.log_level = :debug

  # Use a different logger for distributed setups
  # config.logger = SyslogLogger.new

  # Use a different cache store in production
  # config.cache_store = :mem_cache_store

  # Disable Rails's static asset server
  # In production, Apache or nginx will already do this
  config.serve_static_assets = false

  # Enable serving of images, stylesheets, and javascripts from an asset server
  # config.action_controller.asset_host = "http://assets.example.com"

  # Disable delivery errors, bad email addresses will be ignored
  # config.action_mailer.raise_delivery_errors = false

  # Enable threaded mode
  # config.threadsafe!

  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
  # the I18n.default_locale when a translation can not be found)
  config.i18n.fallbacks = true

  # Send deprecation notices to registered listeners
  config.active_support.deprecation = :notify

  # Compress JavaScripts and CSS
  config.assets.compress = true

  # Choose the compressors to use
  config.assets.js_compressor  = :uglifier
  config.assets.css_compressor = :yui

  # Don't fallback to assets pipeline if a precompiled asset is missed
  config.assets.compile = false

  # Generate digests for assets URLs.
  config.assets.digest = true

  # Defaults to Rails.root.join("public/assets")
  # config.assets.manifest = YOUR_PATH

  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
  # config.assets.precompile += %w( search.js )
end

Edit #2: So I've changed config.assets.digest to false, and now rake assets:precompile runs fine, but when I go to start the server (nginx + passenger phusion) I get the same error with the same trace: `@application.css' is not allowed as an instance variable name

Edit #3: Ok, I've narrowed this down a bit further. It definitely has to do with entries in the public/assets/manifest.yml. I tested this by removing the first entry in the manifest (application.css), and the error changes to reflect the new first entry application.js. Still the same error, just with a new 'instance variable'.

Upvotes: 4

Views: 1242

Answers (1)

Kenny Grant
Kenny Grant

Reputation: 9653

This is probably not the fault of your application.css file. The problem is with psych, probably because it is causing problems loading public/assets/manifest.yml, see this similar error on a braid commit, with a possible solution:

https://github.com/evilchelu/braid/commit/f08fac25570a1a56de8d6282f637d0604ef5e210

Try removing psych, or if that is not possible, look for the problem there. See this part of your stack trace:

 psych.rb:205:in `load_file'

You should be able to find a patch to psych which wil fix this if you want to keep it.

Upvotes: 1

Related Questions