Search code examples
windowssassgulpcompass

gulp-compass fileName error on windows


I'm working with compass/susy for the first time and would like to use liveReload to keep the reloading out of my fingers.

I installed gulp-compass after installing compass itself but it's returning the src file path without quotes, apparently.

Here's my gulpfile.js:

var gulp      = require('gulp'),
compass   = require('gulp-compass');

// Compass
gulp.task('compass', function () {
    gulp.src('sass/*.sass')
    .pipe(compass({
        config_file: './config.rb',
        css: 'css',
        sass: 'sass',
        require: ['susy']
    }))
    .on('error', console.error.bind(console))
    .pipe(gulp.dest('temp/'));
});

And it returns the following error:

Starting 'compass'...
'E:\Program' not recognizes as a internal or external command [...]

{ [Error: Compass failed]
  message: 'Compass failed',
  fileName: 'E:\\Program Files\\wamp\\[...]\\style.sass',
  showStack: false,
  showProperties: true,
  plugin: 'gulp-compass',
  __safety: { toString: [Function] } }

So what I gathered is that the path to source files (which, in my windows, sits inside "E:\Program Files[...]") is being returned without quotes, making the first whitespace character seem like the end of the path, right?

How do I put that inside quotes? I'm doing all this work so I can use gulp with compass, by the way.


Solution

  • I faced the same issue.

    In node_modules\gulp-compass\lib\compass.js on line 78 it all goes wrong:

    options.push(opts.project.replace(/\\/g, '/'));
    

    Somehow when I comment out this line there is no more error. Replacing the \ with /somehow causes the spaces in the path Program Files to fail. Here is line 76 to 81:

    options.push(opts.task);
      if (process.platform === 'win32') {
        // options.push(opts.project.replace(/\\/g, '/')); // <-- this line causes the error
      } else {
       options.push(opts.project);
    }
    

    So, this fixes the problem for now.

    But there should be a better way of fixing this (at least outside of the node_modules folder).