Can't build CSS if you have npm gulp-bless version 3.1.0

Bug #1560739 reported by Aaron Wells
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
High
Unassigned

Bug Description

If you have the npm package "gulp-bless" at version 3.1.0 (which requires the "bless" package at 4.0.0), then Mahara's SASS compilation (make css) will error out.

To replicate:

1. Clone a new Mahara repository, or in an existing Mahara repo rename your "node_modules" directory to "node_modules.bak"
2. Run "npm install" in this repo
3. Run "make css"

Expected result:
Successfully builds the CSS, with this output.

(master)aaronw@vegas:~/www/mahara$ make css
npm install
npm WARN package.json mahara-themes@1.0.0 No repository field.
npm WARN package.json gulp-minify-css@1.2.4 No repository field.
Building CSS...
[13:21:16] Using gulpfile ~/www/mahara/gulpfile.js
[13:21:16] Starting 'css'...
Compiling CSS for htdocs/theme/custom
Compiling CSS for htdocs/theme/default
Compiling CSS for htdocs/theme/modern
Compiling CSS for htdocs/theme/ocean
Compiling CSS for htdocs/theme/primaryschool
Compiling CSS for htdocs/theme/raw
Compiling CSS for htdocs/theme/subthemestarter
[13:21:21] Finished 'css' after 5.72 s
Done!

Actual result:
Errors out with this output.

(master)aaronw@vegas:~/www/mahara-test$ make css
npm install
npm WARN package.json mahara-themes@1.0.0 No repository field.
npm WARN package.json gulp-minify-css@1.2.4 No repository field.
Building CSS...
[13:22:42] Using gulpfile ~/www/mahara-test/gulpfile.js
[13:22:42] Starting 'css'...
Compiling CSS for htdocs/theme/custom
Compiling CSS for htdocs/theme/default
Compiling CSS for htdocs/theme/modern
Compiling CSS for htdocs/theme/ocean
Compiling CSS for htdocs/theme/primaryschool
Compiling CSS for htdocs/theme/raw
Compiling CSS for htdocs/theme/subthemestarter

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot call method 'reduce' of undefined
    at countRules (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/count.js:26:18)
    at count (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/count.js:44:14)
    at chunks$ (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/chunk.js:52:46)
    at tryCatch (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:334:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:105:21)
    at chunk (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/chunk.js:98:113)
    at Object.chunk (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/index.js:34:33)
    at Transform._transform (/home/aaronw/www/mahara-test/node_modules/gulp-bless/index.js:33:36)
    at Transform._read (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
npm WARN package.json mahara-themes@1.0.0 No repository field.
npm WARN package.json gulp-minify-css@1.2.4 No repository field.
[13:22:46] Using gulpfile ~/www/mahara-test/gulpfile.js
[13:22:46] Starting 'css'...
Compiling CSS for htdocs/theme/custom
Compiling CSS for htdocs/theme/default
Compiling CSS for htdocs/theme/modern
Compiling CSS for htdocs/theme/ocean
Compiling CSS for htdocs/theme/primaryschool
Compiling CSS for htdocs/theme/raw
Compiling CSS for htdocs/theme/subthemestarter

events.js:72
        throw er; // Unhandled 'error' event
              ^
TypeError: Cannot call method 'reduce' of undefined
    at countRules (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/count.js:26:18)
    at count (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/count.js:44:14)
    at chunks$ (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/chunk.js:52:46)
    at tryCatch (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:72:40)
    at GeneratorFunctionPrototype.invoke [as _invoke] (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:334:22)
    at GeneratorFunctionPrototype.prototype.(anonymous function) [as next] (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/node_modules/babel-runtime/regenerator/runtime.js:105:21)
    at chunk (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/chunk.js:98:113)
    at Object.chunk (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/bless/lib/index.js:34:33)
    at Transform._transform (/home/aaronw/www/mahara-test/node_modules/gulp-bless/index.js:33:36)
    at Transform._read (/home/aaronw/www/mahara-test/node_modules/gulp-bless/node_modules/through2/node_modules/readable-stream/lib/_stream_transform.js:184:10)
make: *** [css] Error 8

Aaron Wells (u-aaronw)
Changed in mahara:
milestone: none → 15.10.2
Revision history for this message
Aaron Wells (u-aaronw) wrote :

As a temporary measure to get the build working again, I've pinned gulp-bless to 3.0.1 in our node "package.json" file. Commit 805fc0c4ca84366f910c9e955e072fade8cda45d

Revision history for this message
Aaron Wells (u-aaronw) wrote :

It looks like this issue has been logged with the npm "bless" project: https://github.com/BlessCSS/bless/issues/93

Revision history for this message
Aaron Wells (u-aaronw) wrote :

I'm leaving this bug report open until we can figure out a solution that doesn't require us to pin the "gulp-bless" package to an older version.

It looks like this problem is ultimately due to an upstream bug in the "bless" npm package, so probably we'll need to wait until that gets fixed.

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Good news, this is meant to have been fixed in the most recent release of bless.

Revision history for this message
Aaron Wells (u-aaronw) wrote :

Okay, it does work with the latest version of gulp-bless, which in turn relies on version 4.0.2 of node-bless.

But, I don't really know enough about npm to update this without also updating node-sass. And updating that causes these errors when I try to build CSS:

Error in plugin 'sass'
Message:
    htdocs/theme/raw/sass/utilities/_bootstrap-index.scss
Error: File to import not found or unreadable: ../../../lib/bootstrap/assets/stylesheets/bootstrap/mixins
       Parent style sheet: /home/aaronw/www/mahara/htdocs/theme/raw/sass/utilities/_bootstrap-index.scss
        on line 2 of htdocs/theme/raw/sass/utilities/_bootstrap-index.scss
>> @import "../../../lib/bootstrap/assets/stylesheets/bootstrap/mixins";
   ^

And in turn, I'm not exactly sure why that @import line is failing now, when it worked before. Actually, after reading up on SASS and SCSS syntax I'm not sure why that line *ever* worked, because @import is supposed to only work with individual files, not whole directories. It seems like it may be that @import with "bootstrap" works when you're using the "bootstrap-sass" npm module. But, although we're building bootstrap with sass via npm, we are not actually using bootstrap-sass. Instead we've got bootstrap and all its files sitting under htdocs/lib/bootstrap.

So, updating bless would also mean untangling whatever's going on with our Bootstrap setup, and since things are stable as they are, that can wait for now.

Aaron Wells (u-aaronw)
no longer affects: mahara/16.04
no longer affects: mahara/15.10
Changed in mahara:
milestone: 16.04.1 → 16.10.0
no longer affects: mahara/16.10
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 16.10.0 → 16.10.1
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 16.10.1 → 17.04.0
Robert Lyon (robertl-9)
Changed in mahara:
assignee: Aaron Wells (u-aaronw) → nobody
milestone: 17.04.0 → 17.10.0
status: In Progress → Confirmed
importance: Low → High
Revision history for this message
Mahara Bot (dev-mahara) wrote : A patch has been submitted for review

Patch for "master" branch: https://reviews.mahara.org/8024

Robert Lyon (robertl-9)
Changed in mahara:
status: Confirmed → In Progress
Robert Lyon (robertl-9)
Changed in mahara:
milestone: 17.10.0 → 18.04.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/8024
Committed: https://git.mahara.org/mahara/mahara/commit/f3117c35c5cae1af2324a8a7c9f3eca7b4c0d92d
Submitter: Robert Lyon (<email address hidden>)
Branch: master

commit f3117c35c5cae1af2324a8a7c9f3eca7b4c0d92d
Author: Robert Lyon <email address hidden>
Date: Mon Sep 18 13:55:57 2017 +1200

Bug 1560739: Un-pinning gulp-bless

And updating gulp-clean-css to 3x

Run 'npm update' to fetch new versions then 'make css'

behatnotneeded

Change-Id: I51013268a2ad927e96424ab402b6c82f2f906b50
Signed-off-by: Robert Lyon <email address hidden>

Robert Lyon (robertl-9)
Changed in mahara:
status: In Progress → Fix Committed
Robert Lyon (robertl-9)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.