Middleman build fails, but serve works

I’m new to Middleman so not sure if there is some obvious thing I don’t understand, but I’m having trouble building my site. middleman serve works fine, but middleman build fails. Here is error output

       error  build/stylesheets/all.css
       error  build/stylesheets/animate.css
       error  build/stylesheets/primer/css/primer.css
       error  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.css
       error  build/stylesheets/primer/docs/bower_components/octicons/octicons/sprockets-octicons.css
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/components/markdown.css
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/components/user-content.css
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/dist/user-content.css
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/dist/user-content.min.css
       error  build/stylesheets/primer/docs/docs.css
       error  build/stylesheets/primer/scss/primer.css
       error  build/stylesheets/search.css
   identical  build/images/background.png
   identical  build/images/middleman.png
   identical  build/stylesheets/primer/docs/img/apple-touch-icon-precomposed.png
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/keyboard.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/x.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/versions.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/unmute.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/unfold.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/triangle-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/triangle-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/triangle-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/triangle-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/trashcan.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/tools.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/three-bars.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/terminal.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/telescope.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/tag.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/sync.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/stop.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/steps.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/star.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/squirrel.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/split.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/sign-out.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/sign-in.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/settings.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/server.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/search.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/screen-normal.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/screen-full.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/ruby.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/rss.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/rocket.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo-push.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo-pull.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo-forked.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo-force-push.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/repo-clone.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/radio-tower.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/quote.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/alert.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/alignment-align.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/alignment-aligned-to.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/alignment-unalign.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-small-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-small-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-small-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-small-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/arrow-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/beer.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/book.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/bookmark.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/briefcase.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/broadcast.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/browser.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/bug.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/calendar.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/check.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/checklist.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/chevron-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/chevron-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/chevron-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/chevron-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/circle-slash.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/circuit-board.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/clippy.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/clock.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/cloud-download.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/cloud-upload.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/code.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/color-mode.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/comment-discussion.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/comment.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/credit-card.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/dash.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/dashboard.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/database.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/device-camera-video.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/device-camera.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/device-desktop.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/device-mobile.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff-added.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff-ignored.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff-modified.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff-removed.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff-renamed.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/diff.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/ellipsis.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/eye.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-binary.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-code.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-directory.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-media.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-pdf.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-submodule.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-symlink-directory.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-symlink-file.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-text.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/file-zip.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/flame.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/fold.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/gear.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/gift.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/gist-secret.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/gist.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/git-branch.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/git-commit.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/git-compare.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/git-merge.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/git-pull-request.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/globe.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/graph.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/heart.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/history.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/home.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/horizontal-rule.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/hourglass.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/hubot.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/inbox.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/info.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/issue-closed.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/issue-opened.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/issue-reopened.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/jersey.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/jump-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/jump-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/jump-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/jump-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/key.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/question.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/law.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/light-bulb.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/link-external.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/link.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/list-ordered.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/list-unordered.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/location.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/lock.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/logo-github.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mail-read.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mail-reply.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mail.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mark-github.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/markdown.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/megaphone.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mention.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/microscope.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/milestone.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mirror.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mortar-board.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/move-down.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/move-left.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/move-right.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/move-up.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/mute.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/no-newline.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/octoface.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/organization.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/package.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/paintcan.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/pencil.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/person.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/pin.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/playback-fast-forward.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/playback-pause.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/playback-play.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/playback-rewind.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/plug.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/plus.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/podium.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/primitive-dot.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/primitive-square.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/pulse.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/puzzle.svg
       error  build/stylesheets/primer/docs/bower_components/octicons/svg/zap.svg
   identical  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.woff
   identical  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.ttf
   identical  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons-local.ttf
   identical  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.eot
       error  build/javascripts/stats.js
       error  build/stylesheets/primer/Gruntfile.js
       error  build/javascripts/user_info.js
       error  build/javascripts/search.js
       error  build/javascripts/user_utils.js
       error  build/stylesheets/primer/docs/js/anchor.min.js
       error  build/javascripts/renderer.js
       error  build/javascripts/play_tonsser.js
       error  build/javascripts/jumbotron.js
       error  build/javascripts/jquery.js
       error  build/javascripts/handlebars_helpers.js
       error  build/javascripts/handlebars.js
       error  build/javascripts/api.js
       error  build/javascripts/all.js
       error  build/stylesheets/primer/docs/index.html
       error  build/play_tonsser.html
       error  build/search.html
       error  build/stats.html
       error  build/stylesheets/primer/bower.json
       error  build/stylesheets/primer/CLA.html
       error  build/stylesheets/primer/CONTRIBUTING.html
       error  build/stylesheets/primer/docs/about.html
       error  build/stylesheets/primer/docs/alerts.html
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/bower.json
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/CLA.html
       error  build/stylesheets/primer/docs/avatars.html
       error  build/stylesheets/primer/docs/blankslate.html
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/CONTRIBUTING.html
       error  build/stylesheets/primer/docs/bower_components/octicons/bower.json
       error  build/stylesheets/primer/docs/bower_components/octicons/CHANGELOG.html
       error  build/stylesheets/primer/docs/bower_components/primer-user-content/LICENSE.html
       error  build/stylesheets/primer/docs/buttons.html
       error  build/stylesheets/primer/docs/CNAME
       error  build/stylesheets/primer/docs/colors.html
       error  build/stylesheets/primer/docs/bower_components/octicons/CONTRIBUTING.html
       error  build/stylesheets/primer/docs/forms.html
       error  build/stylesheets/primer/docs/guidelines.html
       error  build/index.html
       error  build/jumbotron.html
       error  build/stylesheets/primer/docs/bower_components/octicons/LICENSE.txt
       error  build/stylesheets/primer/docs/layout.html
       error  build/stylesheets/primer/docs/markdown.html
       error  build/stylesheets/primer/docs/nav.html
       error  build/stylesheets/primer/docs/roadmap.html
       error  build/stylesheets/primer/docs/scaffolding.html
       error  build/stylesheets/primer/docs/states.html
       error  build/stylesheets/primer/docs/tooltips.html
       error  build/stylesheets/primer/docs/type.html
       error  build/stylesheets/primer/docs/utilities.html
       error  build/stylesheets/primer/docs/bower_components/octicons/octicons/octicons.less
       error  build/stylesheets/primer/LICENSE.html
       error  build/stylesheets/primer/package.json
       error  build/stylesheets/primer/README.html
       error  build/stylesheets/primer/docs/bower_components/octicons/octicons/README.html
       error  build/stylesheets/primer/docs/bower_components/octicons/README.html
       error  build/user.html
There were errors during this build, re-run with `middleman build --verbose` to see the full exception.

I don’t get much more useful output when I add --verbose.

Any ideas what I’m doing wrong?

Having some --verbose output would help people pinpoint your issue. And, where ever the stacktrace says the problems originates, post the relevant section of the file.

Aside from that, I have had a similar problem, so I will comment on the possibility of your issue being the same as mine. I have found that Middleman acts differently when building the static site (build) and serving the local site (serve). When serving at allows property access to items like article or current_article (i.e. article.url), while when building it requires hash access (i.e. article['url']). I’m still not certain why, but using hash access fixed my problem (tho then I couldn’t serve the site…)