Windows 上未初始化的常量 Sprockets::SassCacheStore 错误(学习 ruby​​ on rails 书)

Posted

技术标签:

【中文标题】Windows 上未初始化的常量 Sprockets::SassCacheStore 错误(学习 ruby​​ on rails 书)【英文标题】:uninitialized constant Sprockets::SassCacheStore Error on Windows (Learn ruby on rails book) 【发布时间】:2015-09-12 14:32:07 【问题描述】:

我是 Web 开发的新手,我一直在学习 David Kehoe 在 Windows 机器上的学习 ruby​​ on rails 教程。在过去的几天里,我一直遇到同样的错误,我尝试了几乎所有可以在互联网上找到的解决方案。

<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><%= content_for?(:title) ? yield(:title) : "Learn Rails" %></title>
    <meta name="description" content="<%= content_for?(:description) ? yield(:description) : "Learn Rails" %>">
    <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
    <%# Modernizr is required for Zurb Foundation %>
    <%= javascript_include_tag 'vendor/modernizr' %>
    <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
    <%= csrf_meta_tags %>
  </head>

问题出在这行:

<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>

我已经安装了 NodeJs,我认为问题出在任何 javascript 文件上,因为如果我去掉那一行,它可以在没有 css 的情况下工作。我也尝试过删除没有帮助的 require 树。

这是我的 Gemfile:

source 'https://rubygems.org'
ruby '2.1.5'
gem 'rails', '4.2.2'


gem 'sqlite3'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

# learn-rails
gem 'activerecord-tableless' 
gem 'compass-rails', '~> 2.0.alpha.0' 
gem 'figaro' 
gem 'gibbon' 
gem 'google_drive' 
gem 'high_voltage' 
gem 'simple_form' 
gem 'zurb-foundation' 
group :development do 
    gem 'better_errors' 
    gem 'quiet_assets' 
    gem 'rails_layout' 
end

还有application.css.scss:

/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
 * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any styles
 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
 * file per style scope.
 *
 *= require_tree .
 *= require_self
 */

还有其他人遇到过这个问题并找到了解决方案吗?

这是当前错误的堆栈跟踪。由于某种原因,它从错误的争论数量(1 比 2)变为(3 比 2):

ArgumentError - wrong number of arguments (3 for 2):
  sprockets (3.2.0) lib/sprockets/sass_cache_store.rb:14:in `_store'
  sass (3.4.15) lib/sass/cache_stores/base.rb:51:in `store'
  sass (3.4.15) lib/sass/engine.rb:414:in `_to_tree'
  sass (3.4.15) lib/sass/engine.rb:309:in `to_tree'
  sass (3.4.15) lib/sass/engine.rb:343:in `_dependencies'
  sass (3.4.15) lib/sass/engine.rb:331:in `dependencies'
  compass-rails (2.0.4) lib/compass-rails/patches/sass_importer.rb:36:in `evalua
te'
  tilt (1.4.1) lib/tilt/template.rb:103:in `render'
  sprockets (3.2.0) lib/sprockets/legacy_tilt_processor.rb:25:in `call'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:57:in `block in call_proces
sors'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
  sprockets (3.2.0) lib/sprockets/loader.rb:86:in `load_asset_by_uri'
  sprockets (3.2.0) lib/sprockets/loader.rb:45:in `block in load'
  sprockets (3.2.0) lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_
cache'
  sprockets (3.2.0) lib/sprockets/loader.rb:38:in `load'
  sprockets (3.2.0) lib/sprockets/cached_environment.rb:20:in `block in initiali
ze'
  sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `load'
  sprockets (3.2.0) lib/sprockets/bundle.rb:23:in `block in call'
  sprockets (3.2.0) lib/sprockets/utils.rb:183:in `dfs'
  sprockets (3.2.0) lib/sprockets/bundle.rb:24:in `call'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:75:in `call_processor'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:57:in `block in call_proces
sors'
  sprockets (3.2.0) lib/sprockets/processor_utils.rb:56:in `call_processors'
  sprockets (3.2.0) lib/sprockets/loader.rb:86:in `load_asset_by_uri'
  sprockets (3.2.0) lib/sprockets/loader.rb:45:in `block in load'
  sprockets (3.2.0) lib/sprockets/loader.rb:155:in `fetch_asset_from_dependency_
cache'
  sprockets (3.2.0) lib/sprockets/loader.rb:38:in `load'
  sprockets (3.2.0) lib/sprockets/cached_environment.rb:20:in `block in initiali
ze'
  sprockets (3.2.0) lib/sprockets/cached_environment.rb:47:in `load'
  sprockets (3.2.0) lib/sprockets/base.rb:63:in `find_asset'
  sprockets (3.2.0) lib/sprockets/environment.rb:30:in `find_asset'
  sprockets (3.2.0) lib/sprockets/base.rb:89:in `[]'
  sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:230:in `lookup_asset_for
_path'
  sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:190:in `check_errors_for
'
  sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:159:in `block in stylesh
eet_link_tag'
  sprockets-rails (2.3.2) lib/sprockets/rails/helper.rb:158:in `stylesheet_link_
tag'
  app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_ht
ml_erb___453486602_48019296'
  actionview (4.2.2) lib/action_view/template.rb:145:in `block in render'
  activesupport (4.2.2) lib/active_support/notifications.rb:166:in `instrument'
  actionview (4.2.2) lib/action_view/template.rb:333:in `instrument'
  actionview (4.2.2) lib/action_view/template.rb:143:in `render'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:66:in `render
_with_layout'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:52:in `render
_template'
  actionview (4.2.2) lib/action_view/renderer/template_renderer.rb:14:in `render
'
  actionview (4.2.2) lib/action_view/renderer/renderer.rb:42:in `render_template
'
  actionview (4.2.2) lib/action_view/renderer/renderer.rb:23:in `render'
  actionview (4.2.2) lib/action_view/rendering.rb:100:in `_render_template'
  actionpack (4.2.2) lib/action_controller/metal/streaming.rb:217:in `_render_te
mplate'
  actionview (4.2.2) lib/action_view/rendering.rb:83:in `render_to_body'
  actionpack (4.2.2) lib/action_controller/metal/rendering.rb:32:in `render_to_b
ody'
  actionpack (4.2.2) lib/action_controller/metal/renderers.rb:37:in `render_to_b
ody'
  actionpack (4.2.2) lib/abstract_controller/rendering.rb:25:in `render'
  actionpack (4.2.2) lib/action_controller/metal/rendering.rb:16:in `render'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:44:in `block
 (2 levels) in render'
  activesupport (4.2.2) lib/active_support/core_ext/benchmark.rb:12:in `block in
 ms'
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/benchmark.rb:294:in `realtime'
  activesupport (4.2.2) lib/active_support/core_ext/benchmark.rb:12:in `ms'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:44:in `block
 in render'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:87:in `clean
up_view_runtime'
  activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:25:in `c
leanup_view_runtime'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:43:in `rende
r'
  actionpack (4.2.2) lib/action_controller/metal/implicit_render.rb:10:in `defau
lt_render'
  actionpack (4.2.2) lib/action_controller/metal/implicit_render.rb:5:in `send_a
ction'
  actionpack (4.2.2) lib/abstract_controller/base.rb:198:in `process_action'
  actionpack (4.2.2) lib/action_controller/metal/rendering.rb:10:in `process_act
ion'
  actionpack (4.2.2) lib/abstract_controller/callbacks.rb:20:in `block in proces
s_action'
  activesupport (4.2.2) lib/active_support/callbacks.rb:117:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:555:in `block (2 levels)
 in compile'
  activesupport (4.2.2) lib/active_support/callbacks.rb:505:in `call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:92:in `_run_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:776:in `_run_process_act
ion_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.2) lib/abstract_controller/callbacks.rb:19:in `process_action'

  actionpack (4.2.2) lib/action_controller/metal/rescue.rb:29:in `process_action
'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:32:in `block
 in process_action'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `block in ins
trument'
  activesupport (4.2.2) lib/active_support/notifications/instrumenter.rb:20:in `
instrument'
  activesupport (4.2.2) lib/active_support/notifications.rb:164:in `instrument'
  actionpack (4.2.2) lib/action_controller/metal/instrumentation.rb:30:in `proce
ss_action'
  actionpack (4.2.2) lib/action_controller/metal/params_wrapper.rb:250:in `proce
ss_action'
  activerecord (4.2.2) lib/active_record/railties/controller_runtime.rb:18:in `p
rocess_action'
  actionpack (4.2.2) lib/abstract_controller/base.rb:137:in `process'
  actionview (4.2.2) lib/action_view/rendering.rb:30:in `process'
  actionpack (4.2.2) lib/action_controller/metal.rb:196:in `dispatch'
  actionpack (4.2.2) lib/action_controller/metal/rack_delegation.rb:13:in `dispa
tch'
  actionpack (4.2.2) lib/action_controller/metal.rb:237:in `block in action'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:74:in `dispatch'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:43:in `serve'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:43:in `block in serve
'
  actionpack (4.2.2) lib/action_dispatch/journey/router.rb:30:in `serve'
  actionpack (4.2.2) lib/action_dispatch/routing/route_set.rb:819:in `call'
  rack (1.6.4) lib/rack/etag.rb:24:in `call'
  rack (1.6.4) lib/rack/conditionalget.rb:25:in `call'
  rack (1.6.4) lib/rack/head.rb:13:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call
'
  actionpack (4.2.2) lib/action_dispatch/middleware/flash.rb:260:in `call'
  rack (1.6.4) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.6.4) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/cookies.rb:560:in `call'
  activerecord (4.2.2) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.2.2) lib/active_record/connection_adapters/abstract/connection
_pool.rb:649:in `call'
  activerecord (4.2.2) lib/active_record/migration.rb:378:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in
 call'
  activesupport (4.2.2) lib/active_support/callbacks.rb:88:in `_run_callbacks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:776:in `_run_call_callba
cks'
  activesupport (4.2.2) lib/active_support/callbacks.rb:81:in `run_callbacks'
  actionpack (4.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  better_errors (2.1.1) lib/better_errors/middleware.rb:84:in `protected_app_cal
l'
  better_errors (2.1.1) lib/better_errors/middleware.rb:79:in `better_errors_cal
l'
  better_errors (2.1.1) lib/better_errors/middleware.rb:57:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `c
all'
  web-console (2.1.3) lib/web_console/middleware.rb:37:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `ca
ll'
  railties (4.2.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `block in tag
ged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.2) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.2) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.1.0) lib/quiet_assets.rb:27:in `call_with_quiet_assets'
  actionpack (4.2.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.2) lib/active_support/cache/strategy/local_cache_middleware
.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.2) lib/action_dispatch/middleware/static.rb:113:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.2) lib/rails/engine.rb:518:in `call'
  railties (4.2.2) lib/rails/application.rb:164:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:138:in `servi
ce'
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:94:in `run'
  C:/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/server.rb:295:in `block in
start_thread'

【问题讨论】:

【参考方案1】:

您使用的是旧的 alpha 版本的指南针,这是 known issue。

看完这个 Github Issue 听起来 gems 的工作组合是:

gem 'sass-rails', '~> 5.0'
gem 'compass-rails', '~> 2.0.4'

应该可以的。

【讨论】:

感谢您的回复。好的,我在我的 Gemfile 中将 compass-rails 更改为 2.0.4,我还必须将 Sass-rails 更改为 5.0.1 但现在我在命令行中收到此错误:C:/RailsInstaller/Ruby2.1.0/lib/ ruby/gems/2.1.0/gems/sass-rails-5.0.1/lib/sass/rails/helpers.rb:11:in `': 未初始化的常量 Sass::Script (NameError ) 以及之后的更多行。我做错了吗? 你不是。查看这个问题github.com/rails/sass-rails/issues/315 尝试专门声明 gem 'sass-rails', '~> 5.0.3'` 是的,我更改了它,但现在我收到错误:ArgumentError at / wrong number of arguments (1 for 2) when I am on local host. 你能发布一个堆栈跟踪吗? 非常感谢!当我添加 gem "compass-rails", github: "Compass/compass-rails", branch: "master" 和 gem 'sprockets', '2.11.0' 然后运行包更新时,它起作用了。你帮了大忙。【参考方案2】:

我刚刚点击了这个,以下对我有用(正如 Zuru 在子评论中提到的那样 - 发布以便于阅读)。

gem "compass-rails", github: "Compass/compass-rails", branch: "master"
gem 'sprockets', '2.11.0

【讨论】:

您在 sprockets 版本号后面缺少引号,我想添加它,但由于它太短,修改堆栈溢出拒绝我的编辑

以上是关于Windows 上未初始化的常量 Sprockets::SassCacheStore 错误(学习 ruby​​ on rails 书)的主要内容,如果未能解决你的问题,请参考以下文章

react-native-camera 无法读取 android 上未定义的属性“常量”

Visual Studio 10:我的 Windows 10 上未声明 Saxxmlreader

Pyside:windows7上未解决的函数错误消息

markdown https://github.com/sprocket-inc/core-jssdk/pull/111

adb 在 Windows 上未被识别为内部或外部命令

在 Windows 命令提示符下检测到 BigQuery,但在 Bash 上未检测到