Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does `middleman serve` work, but `middleman build` fails to compile this Sass?

When I just run middleman to serve, all.css gets compiled fine, consisting of just a call to +box-shadow(none):

/* line 1, /home/yang/asdf/source/stylesheets/content.css.sass */
div {
  -webkit-box-shadow: none;
  -moz-box-shadow: none;
  box-shadow: none; }

But when I build the site, I get this Sass/Compass error:

$ middleman build
Slim::EmbeddedEngine is deprecated, it is called Slim::Embedded in Slim 2.0
Slim::EmbeddedEngine is deprecated, it is called Slim::Embedded in Slim 2.0
Slim::EmbeddedEngine is deprecated, it is called Slim::Embedded in Slim 2.0
/home/yang/asdf/source/stylesheets/content.css.sass:2:in `box-shadow': Undefined mixin 'box-shadow'. (Sass::SyntaxError)
  (in /home/yang/asdf/source/stylesheets/content.css.sass:2)
        from /home/yang/asdf/source/stylesheets/content.css.sass:2
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:253:in `visit_mixin'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `map'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `block in visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:320:in `visit_rule'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `map'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:53:in `visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `block in visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/base.rb:37:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:100:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/visitors/perform.rb:7:in `visit'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/tree/root_node.rb:20:in `render'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/engine.rb:315:in `_render'
        from /var/lib/gems/1.9.1/gems/sass-3.2.7/lib/sass/engine.rb:262:in `render'
        from /var/lib/gems/1.9.1/gems/sprockets-sass-0.9.1/lib/sprockets/sass/sass_template.rb:40:in `evaluate'
        from /var/lib/gems/1.9.1/gems/tilt-1.3.7/lib/tilt/template.rb:77:in `render'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/context.rb:197:in `block in evaluate'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/context.rb:194:in `each'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/context.rb:194:in `evaluate'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/processed_asset.rb:12:in `initialize'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:374:in `new'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:374:in `block in build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:395:
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:373:in `build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:94:in `block in build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/caching.rb:51:in `cache_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:93:in `build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:287:in `find_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:61:in `find_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/bundled_asset.rb:16:in `initialize'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:377:in `new'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:377:in `build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:94:in `block in build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/caching.rb:51:in `cache_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:93:in `build_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/base.rb:287:in `find_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/index.rb:61:in `find_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/environment.rb:75:in `find_asset'
        from /var/lib/gems/1.9.1/gems/sprockets-2.9.2/lib/sprockets/server.rb:47:in `call'
        from /var/lib/gems/1.9.1/gems/middleman-sprockets-3.0.11/lib/middleman-sprockets/extension.rb:200:in `call'
        from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
        from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/urlmap.rb:64:in `block in call'
        from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `each'
        from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/urlmap.rb:49:in `call'
        from /var/lib/gems/1.9.1/gems/middleman-more-3.0.13/lib/middleman-more/extensions/minify_javascript.rb:51:in `call'
        from /var/lib/gems/1.9.1/gems/middleman-more-3.0.13/lib/middleman-more/extensions/minify_css.rb:50:in `call'
        from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:134:in `call'
        from /var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/mock_session.rb:30:in `request'
        from /var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/test.rb:230:in `process_request'
        from /var/lib/gems/1.9.1/gems/rack-test-0.6.2/lib/rack/test.rb:57:in `get'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli/build.rb:259:in `block in execute!'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli/build.rb:256:in `each'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli/build.rb:256:in `execute!'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli/build.rb:198:in `invoke!'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/actions.rb:95:in `action'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli/build.rb:65:in `build'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:27:in `run'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli.rb:77:in `method_missing'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:29:in `run'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/task.rb:126:in `run'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/invocation.rb:120:in `invoke_task'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor.rb:275:in `dispatch'
        from /var/lib/gems/1.9.1/gems/thor-0.15.4/lib/thor/base.rb:425:in `start'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/lib/middleman-core/cli.rb:22:in `start'
        from /var/lib/gems/1.9.1/gems/middleman-core-3.0.13/bin/middleman:18:in `<top (required)>'
        from /usr/local/bin/middleman:19:in `load'
        from /usr/local/bin/middleman:19:in `<main>'

I have reproduced this in the following small simple example, which I've also included as a base64-encoded tar.gz at the bottom if you want to repro locally. It also includes the full backtrace.

Here's the tree of files:

asdf
├── config.rb
├── config.ru
├── error
├── Gemfile
├── Gemfile.lock
├── source
│   └── stylesheets
│       ├── all.css.sass
│       └── content.css.sass

Here are all the file contents:

config.rb:

require 'animate-sass'
require 'susy'
require 'slim'
set :css_dir, 'stylesheets'
set :js_dir, 'javascripts'
set :images_dir, 'images'
set :fonts_dir, 'fonts'
configure :build do
  activate :minify_css
  activate :minify_javascript
  activate :relative_assets
  require "middleman-smusher"
  activate :smusher

config.ru:

require 'rubygems'
require 'middleman/rack'
run Middleman.server

Gemfile:

source :rubygems
gem "slim"
gem "susy"
gem "animate-sass"
gem "middleman", "~>3.0.13"
gem "middleman-smusher"

Gemfile.lock: see tar.gz

all.css.sass:

@import compass/css3/box-shadow
@import content

content.css.sass:

div
  +box-shadow(none)

Here's the base64-encodede tar.gz, which you can decode with base64 -d:

H4sIADhQcFEAA+0ca3Mbt1Gf+SsQujOiW/GePFLixJo4juK2Ezsau55+vEJ3oAjrHixwJ0uZTH57
F497UZRFSTzZbrAfbBIL7Au7e7s4iJjHC5swlrO93sABmE4n4n93Frj6f0+OO47nBL6/53quP3EC
x/FhnusGXrCHnP5EaqDkBWYI7V3j7Pxz8+7Cf6PwF5TSOE5IijN0VtIkHrxPaDqfn6RnJI5JfJKd
04wgylFMVoxEuCDxAaKFGIlwkpAYdRcgmskR5FnOV0vLXuYpscWW2lgEAM9LFhGbF9cJ4UtCCm5H
eVaQrLAizi2OOZ97c6Dwn7P8asyXOM4/7c/RhywmCxAjBiNeAXa/hbXQ6L1YNn9/nRX46kSE2PMB
QiOY9yD2YrGCBcvTh9FYI3GJmZ3QM/ucpNx2rSPLVR/F5LFvedZMosVXu2CE2JeU0yJn3F4RtshZ
arGzuRf40jISF0pD7O+MzxnmRDDxZw2P3VFvaeE6Th8cKvm1jc6SPLoQnqiMFS0h4BjpwV6aX4pX
vdHuS4XOphw9jdnaPD1X8vxEi2VIskvK8iyFKOpJwcNebbkWPl079qKR77XiKGRlQkwyMMnAJIM/
ZTJwvbZGLM97CKZvNRm0OOxSA2HkMMtjaRudi8GLYsIeQ5rIalua2w0kzXCXRL2p9xBBVww8GArd
saTuSIykXiEUH/FPWJB0lUCTINhNlFnIJU5KGNqWX0GTYuxavtZBfLXbZGezRynhwaC3Jr+s4K8K
6YZHa2F7X/HvwWmi7IOjZX/Edyq9+EA4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TQIAeAAA

Thanks in advance for any help!

like image 209
Yang Avatar asked Apr 19 '13 00:04

Yang


2 Answers

This turned out to be due to some files that aren't meant to be output having names that do not start with an underscore. E.g., content.css.sass should be _content.css.sass, so that middleman knows not to try to build that file directly. (We aren't really familiar with middleman etc. - this was a bundle handed to us, so it took a while to track this down.)

like image 52
Yang Avatar answered Nov 05 '22 01:11

Yang


So I bumped into this and wanted to give a more precise answer:

Any @imported file in the chain downstream from a non-underscore named file will break with an error such as Sass::SyntaxError Undefined Variable or Undefined mixin.

It's as simple as making sure every file in the chain starts with an underscore; sometimes very easy to pass by!

like image 28
kross Avatar answered Nov 05 '22 01:11

kross