Sass::SyntaxError:未找到要导入的文件或无法读取:生产中的指南针 [英] Sass::SyntaxError: File to import not found or unreadable: compass in production

查看:31
本文介绍了Sass::SyntaxError:未找到要导入的文件或无法读取:生产中的指南针的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 SASS + Compass 和控制器特定的样式表,所以在我的 application.html.erb 中设置:

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" %>

所以我放了一个 home.css(清单):

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

/*
*= require_self
*= require homepage
*/

我的主页.css.scss:

My homepage.css.scss:

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

...

在我的主页中,即使在生产中也可以,但是当我尝试访问其他页面(如/tags)时,我收到此错误:Sass::SyntaxError: File to import not found or unreadable: compass.加载路径:/home/user/apps/www.mysite.com/releases/20140416112240(在/home/user/apps/www.mysite.com/releases/20140416112240/app/assets/stylesheets/tags.css.scss)

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)

我不知道是否必须在每个控制器特定的 .scss 文件中设置 @import "compass"; 并且我不知道如何修复这个错误.

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

我的 application.rb:

My application.rb:

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

tags.css.scss:

tags.css.scss:

@import "compass";

...

宝石文件

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

完全错误:

[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.2.1/lib/omniauth/strategy.rb:164:in `call'
[GEM_ROOT]/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:186:in `call!'
[GEM_ROOT]/gems/omniauth-1.2.1/lib/omniauth/strategy.rb:164:in `call'
[GEM_ROOT]/gems/omniauth-1.2.1/lib/omniauth/builder.rb:59:in `call'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/rack/error_collector.rb:55:in `call'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/rack/agent_hooks.rb:32:in `call'
[GEM_ROOT]/gems/newrelic_rpm-3.7.2.195/lib/new_relic/rack/browser_monitoring.rb:27:in `call'
[GEM_ROOT]/gems/rack-mobile-detect-0.4.0/lib/rack/mobile-detect.rb:164:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/etag.rb:23:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/conditionalget.rb:25:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/head.rb:14:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/flash.rb:242:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:210:in `context'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/session/abstract/id.rb:205:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/cookies.rb:341:in `call'
[GEM_ROOT]/gems/activerecord-3.2.17/lib/active_record/query_cache.rb:64:in `call'
[GEM_ROOT]/gems/activerecord-3.2.17/lib/active_record/connection_adapters/abstract/connection_pool.rb:479:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `_run__418469082141364769__call__3430351747359415792__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_call_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/action_dispatch/middleware/callbacks.rb:27:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/rack/logger.rb:32:in `call_app'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/rack/logger.rb:16:in `block in call'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/tagged_logging.rb:22:in `tagged'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/rack/logger.rb:16:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/request_id.rb:22:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/methodoverride.rb:21:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/runtime.rb:17:in `call'
[GEM_ROOT]/gems/activesupport-3.2.17/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
[GEM_ROOT]/gems/rack-1.4.5/lib/rack/lock.rb:15:in `call'
[GEM_ROOT]/gems/actionpack-3.2.17/lib/action_dispatch/middleware/static.rb:63:in `call'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
[GEM_ROOT]/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
[GEM_ROOT]/gems/utf8-cleaner-0.0.6/lib/utf8-cleaner/middleware.rb:18:in `call'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/engine.rb:484:in `call'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/application.rb:231:in `call'
[GEM_ROOT]/gems/railties-3.2.17/lib/rails/railtie/configurable.rb:30:in `method_missing'
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.4/lib/phusion_passenger/rack/thread_handler_extension.rb:77:in `process_request'
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.4/lib/phusion_passenger/request_handler/thread_handler.rb:140:in `accept_and_process_next_request'
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.4/lib/phusion_passenger/request_handler/thread_handler.rb:108:in `main_loop'
/usr/local/rvm/gems/ruby-1.9.3-head/gems/passenger-4.0.4/lib/phusion_passenger/request_handler.rb:441:in `block (3 levels) in start_threads'

推荐答案

将此添加到对我有用的初始化程序

adding this to an initializer worked for me

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

这篇关于Sass::SyntaxError:未找到要导入的文件或无法读取:生产中的指南针的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆