资产中缺少文件错误:预先计算RAILS_ENV =生产,但不是开发

时间:2015-09-21 20:25:33

标签: ruby-on-rails twitter-bootstrap spree bootstrap-sass

尝试运行

RAILS_ENV=production bundle exec rake assets:precompile

给出错误:

Sass::SyntaxError: File to import not found or unreadable: *.
Load path: /home/vagrant/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.5.1/assets/stylesheets

如果我使用RAILS_ENV =开发,一切都会正常进行,没有错误。为什么会发生这种情况?

我该如何解决这个问题?该应用程序使用Spree 3.x,其中包括Bootstrap-SASS

编辑:我已经解决了这个错误,但希望能更深入地理解这个错误的原因。

我通过将application.css复制到application.css.scss并从application.css中删除所有内容来解决这个问题。

我的猜测是需要从其他SASS文件中包含SASS文件才能使预处理器正常工作。那是对的吗?还有更多吗?我很乐意upvote /接受一个解释这个的答案。

这是我的Gemfile:

source 'https://rubygems.org'

ruby '2.2.2'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.3' 
#gem 'rails', github: 'rails/rails'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug'

  # Access an IRB console on exception pages or by using <%= console %> in views
  gem 'web-console', '~> 2.0'
end


# group :development do
#   gem 'rails-dev-boost', :git => 'git://github.com/thedarkone/rails-dev-boost.git' #speed up development
#   gem 'rb-inotify', '>= 0.8.8'
# end

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

gem 'spree', branch: '3-0-stable'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '3-0-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '3-0-stable'

gem 'pg'
gem 'spree_i18n', git: 'git://github.com/spree/spree_i18n.git', branch: '3-0-stable'

gem 'spree_yadav_jewelry', :path => 'extensions/spree_yadav_jewelry'
gem 'spree_yadav_diamonds', :path => 'extensions/spree_yadav_diamonds'

gem 'has_scope'

这是完整的错误输出:

rake aborted!
Sass::SyntaxError: File to import not found or unreadable: *.
Load path: /home/vagrant/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.5.1/assets/stylesheets
(sass):18
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:67:in `rescue in import'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:45:in `import'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:28:in `imported_file'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:37:in `css_import?'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:311:in `visit_import'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:79:in `block in with_base'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:115:in `with_frame'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:79:in `with_base'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:158:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `map'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:166:in `visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:186:in `visit_root'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:157:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:8:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/root_node.rb:36:in `css_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/root_node.rb:20:in `render'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/engine.rb:278:in `render'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/sass_compressor.rb:48:in `call'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/sass_compressor.rb:28:in `call'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:60:in `block in load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:316:in `fetch_asset_from_dependency_cache'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:44:in `load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:47:in `yield'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:47:in `load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/base.rb:66:in `find_asset'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:138:in `block in find'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:204:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:204:in `stat_directory'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:222:in `stat_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:105:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:104:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:104:in `logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:136:in `find'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:162:in `compile'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Sass::SyntaxError: File to import not found or unreadable: *.
Load path: /home/vagrant/.rvm/gems/ruby-2.2.2/gems/bootstrap-sass-3.3.5.1/assets/stylesheets
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:65:in `import'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:28:in `imported_file'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/import_node.rb:37:in `css_import?'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:311:in `visit_import'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:158:in `block in visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:79:in `block in with_base'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:115:in `with_frame'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/stack.rb:79:in `with_base'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:158:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `block in visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `map'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:52:in `visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:167:in `block in visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:179:in `with_environment'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:166:in `visit_children'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `block in visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:186:in `visit_root'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/base.rb:36:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:157:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/visitors/perform.rb:8:in `visit'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/root_node.rb:36:in `css_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/tree/root_node.rb:20:in `render'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sass-3.4.18/lib/sass/engine.rb:278:in `render'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/sass_compressor.rb:48:in `call'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/sass_compressor.rb:28:in `call'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:60:in `block in load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:316:in `fetch_asset_from_dependency_cache'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/loader.rb:44:in `load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:47:in `yield'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/cached_environment.rb:47:in `load'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/base.rb:66:in `find_asset'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:138:in `block in find'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:223:in `block in stat_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:207:in `block in stat_directory'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:204:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:204:in `stat_directory'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/path_utils.rb:222:in `stat_tree'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:105:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:104:in `each'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/legacy.rb:104:in `logical_paths'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:136:in `find'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/sprockets/manifest.rb:162:in `compile'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-3.3.4/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/vagrant/.rvm/gems/ruby-2.2.2/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile

application.css看起来像这样,没有从基本设置做出任何更改:

/*
 * 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 any plugin's vendor/assets/stylesheets directory 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
 */

@import "*"

1 个答案:

答案 0 :(得分:0)

我通过将application.css复制到application.css.scss并从application.css中删除所有内容来解决这个问题。