我正在使用Rails 4.2和Capistrano 3.当我运行bundle exec rake assets:precompile
时,一切都很好用,但是当我使用Capistrano部署网站时,我在资产:预编译步骤中遇到了这个错误。
Tasks: TOP => deploy:assets:precompile
(See full trace by running task with --trace)
The deploy has failed with an error: Exception while executing as xxx@123.45.67.89: rake exit status: 1
rake stdout: rake aborted!
Sass::SyntaxError: Invalid CSS after " */": expected "}", was ""
(sass):6831
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1161:in `expected'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1097:in `expected'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:1092:in `tok!'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:639:in `block'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:631:in `ruleset'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:656:in `block_child'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:649:in `block_contents'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:117:in `stylesheet'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/scss/parser.rb:42:in `parse'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/engine.rb:403:in `_to_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sass-3.4.19/lib/sass/engine.rb:278:in `render'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/sass_compressor.rb:48:in `call'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/sass_compressor.rb:28:in `call'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:75:in `call_processor'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:57:in `block in call_processors'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:56:in `reverse_each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/processor_utils.rb:56:in `call_processors'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:134:in `load_from_unloaded'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:60:in `block in load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:318:in `fetch_asset_from_dependency_cache'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/loader.rb:44:in `load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:20:in `block in initialize'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:47:in `yield'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/cached_environment.rb:47:in `load'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/base.rb:66:in `find_asset'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/base.rb:73:in `find_all_linked_assets'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:142:in `block in find'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:114:in `block (2 levels) in logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:225:in `block in stat_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:209:in `block in stat_directory'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:206:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:206:in `stat_directory'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/path_utils.rb:224:in `stat_tree'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:105:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:105:in `block in logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:104:in `each'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/legacy.rb:104:in `logical_paths'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:140:in `find'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/sprockets/manifest.rb:168:in `compile'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-3.5.0/lib/rake/sprocketstask.rb:147:in `with_logger'
/home/xxx/Sites/my-app/shared/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.3/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'
Tasks: TOP => assets:precompile
(See full trace by running task with --trace)
rake stderr: Nothing written
我注意到如果删除*= require styles
文件中的行application.css
,它会成功部署,但显然这不是我要找的解决方案。我的资产/样式表文件结构如下所示:
答案 0 :(得分:0)
运行以下命令在您的开发环境中本地编译资产:
rake assets:precompile
在部署capistrano
期间,正在调用以下任务(正如您在回溯之上看到的那样):
cap env_name deploy:assets:precompile
它的部分在远程服务器上调用它:
rake assets:precompile
开发环境中的资源预编译忽略语法错误。
尝试在本地运行此命令以查找并修复这些错误:
RAILS_ENV=production rake assets:precompile --trace