Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
331 views
in Technique[技术] by (71.8m points)

ruby on rails - Sass::SyntaxError: File to import not found or unreadable: compass in production

I'm using SASS + Compass and controller specific stylesheets, so in my application.html.erb I set:

<%= stylesheet_link_tag "home", params[:controller], :media => "all" %>

So I have a home.css (manifest) that I put:

/*
*= require_self
*= require homepage
*/

My homepage.css.scss:

@import "sass/_all";
@import "bootstrap";
@import "compass";

...

It's ok in my homepage even in production, but when I try to vsit other page (like /tags) I get this error: Sass::SyntaxError: File to import not found or unreadable: compass. Load path: /home/user/apps/www.mysite.com/releases/20140416112240 (in /home/user/apps/www.mysite.com/releases/20140416112240/app/assets/stylesheets/tags.css.scss)

I dont know if I must set @import "compass"; in every controller specific .scss file and I dont know how to fix this error.

My application.rb:

config.assets.precompile += ['homepage.js', 'home.css', 'admin.js']

tags.css.scss:

@import "compass";

...

Gemfile

group :assets do
  gem 'sass-rails', '>= 3.2'
  gem 'coffee-rails', "~> 3.2.1"
  gem 'uglifier', '>=1.0.3'
  gem 'bootstrap-sass', '~> 3.1.1'
  gem 'compass-rails'
  gem 'turbo-sprockets-rails3'
end

Full error:

[PROJECT_ROOT]/app/assets/stylesheets/tags.css.scss:1:in `'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/import_node.rb:67:in `rescue in import'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/import_node.rb:45:in `import'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/import_node.rb:28:in `imported_file'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/import_node.rb:37:in `css_import?'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:217:in `visit_import'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `map'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:53:in `visit_children'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `block in visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/base.rb:37:in `visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:100:in `visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/visitors/perform.rb:7:in `visit'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/tree/root_node.rb:20:in `render'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/engine.rb:315:in `_render'
[GEM_ROOT]/gems/sass-3.2.14/lib/sass/engine.rb:262:in `render'
[GEM_ROOT]/gems/tilt-1.4.1/lib/tilt/css.rb:24:in `evaluate'
[GEM_ROOT]/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/context.rb:193:in `block in evaluate'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `each'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/context.rb:190:in `evaluate'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/processed_asset.rb:12:in `initialize'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `new'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:249:in `block in build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:270:in `circular_call_protection'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:248:in `build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `new'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:252:in `build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:93:in `block in build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/caching.rb:19:in `cache_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:92:in `build_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:169:in `find_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/index.rb:60:in `find_asset'
[GEM_ROOT]/gems/sprockets-2.2.2/lib/sprockets/base.rb:177:in `[]'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:137:in `digest_for'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:151:in `rewrite_asset_path'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/asset_paths.rb:27:in `compute_public_path'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:56:in `asset_path'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:49:in `block in stylesheet_link_tag'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:43:in `collect'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/sprockets/helpers/rails_helper.rb:43:in `stylesheet_link_tag'
[GEM_ROOT]/gems/mobile-fu-1.3.1/lib/mobile-fu/helper.rb:41:in `stylesheet_link_tag_with_mobilization'
[PROJECT_ROOT]/app/views/layouts/v3.html.erb:10:in `_app_views_layouts_v__html_erb__3876105138336677513_49934580'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/template.rb:145:in `block in render'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/notifications.rb:125:in `instrument'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/template.rb:143:in `render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/renderer/template_renderer.rb:45:in `render_template'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/renderer/template_renderer.rb:18:in `render'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:160:in `block in render_with_newrelic'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:159:in `render_with_newrelic'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/renderer/renderer.rb:36:in `render_template'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_view/renderer/renderer.rb:17:in `render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/rendering.rb:110:in `_render_template'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/streaming.rb:225:in `_render_template'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/rendering.rb:103:in `render_to_body'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/renderers.rb:28:in `render_to_body'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/compatibility.rb:50:in `render_to_body'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/rendering.rb:88:in `render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/rendering.rb:16:in `render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:40:in `block (2 levels) in render'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/core_ext/benchmark.rb:5:in `block in ms'
/usr/local/rvm/rubies/ruby-1.9.3-head/lib/ruby/1.9.1/benchmark.rb:295:in `realtime'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/core_ext/benchmark.rb:5:in `ms'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:40:in `block in render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:83:in `cleanup_view_runtime'
[GEM_ROOT]/gems/activerecord-3.2.17/lib/active_record/railties/controller_runtime.rb:24:in `cleanup_view_runtime'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:39:in `render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/implicit_render.rb:10:in `default_render'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/implicit_render.rb:5:in `send_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/base.rb:167:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/rendering.rb:10:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/callbacks.rb:18:in `block in process_action'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:425:in `_run__170333789554272889__process_action__2850358255668549627__callbacks'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `__run_callback'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:385:in `_run_process_action_callbacks'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:81:in `run_callbacks'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/callbacks.rb:17:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/rescue.rb:29:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:30:in `block in process_action'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/notifications.rb:123:in `block in instrument'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/notifications.rb:123:in `instrument'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/instrumentation.rb:29:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/params_wrapper.rb:207:in `process_action'
[GEM_ROOT]/gems/activerecord-3.2.17/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:38:in `block in process_action'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:339:in `perform_action_with_newrelic_trace'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/agent/instrumentation/rails3/action_controller.rb:37:in `process_action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/base.rb:121:in `process'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/abstract_controller/rendering.rb:45:in `process'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal.rb:203:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_controller/metal.rb:246:in `block in action'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/routing/route_set.rb:73:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/routing/route_set.rb:36:in `call'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:68:in `block in call'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:56:in `each'
[GEM_ROOT]/gems/journey-1.0.4/lib/journey/router.rb:56:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/routing/route_set.rb:608:in `call'
[GEM_ROOT]/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[GEM_ROOT]/gems/omniauth-1

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

adding this to an initializer worked for me

require 'compass'
Sass.load_paths << Compass::Frameworks['compass'].stylesheets_directory

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...