Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--gulpfile failed on Windows in Node v0.11.13 #664

Closed
jwu opened this issue Sep 5, 2014 · 22 comments
Closed

--gulpfile failed on Windows in Node v0.11.13 #664

jwu opened this issue Sep 5, 2014 · 22 comments
Labels

Comments

@jwu
Copy link

jwu commented Sep 5, 2014

When I using gulp on Windows platform with Node v0.11.13 and running command:

gulp --gulpfile mygulp.js

It will report error:

Task 'default' is not in your gulpfile.

However I have default task define on it. Mac/Linux platform are OK. And if I change my node to v0.10 on Windows, it also successfully running.

So I guess the gulp --gulpfile failed on Windows in Node v0.11.13

@yocontra
Copy link
Member

yocontra commented Sep 5, 2014

Can you show your gulpfile and your log?

@jwu
Copy link
Author

jwu commented Sep 5, 2014

This is my gulpfile.js:

var gulp = require('gulp');
var clean = require('gulp-clean');
var gutil = require('gulp-util');

var paths = {
    ext_core: [ 
        'core/bin/core.dev.js',
        'core/bin/core.min.js',
    ],
    ext_engine: [ 
        'engine/bin/engine.dev.js',
        'engine/bin/engine.min.js',
    ],
    ext_editor_ui: [ 
        'editor-ui/bin/editor-ui.css',
        'editor-ui/bin/editor-ui.html',
        'editor-ui/bin/img/**/*.png',
    ],
    ext_editor: [ 
        'editor/bin/editor.html',
        'editor/bin/editor.dev.js',
        'editor/bin/editor.min.js',
    ],
    editor_misc: [ 
        'editor/favicon.ico',
        'editor/index.html',
    ],
};

/////////////////////////////////////////////////////////////////////////////
// copy
/////////////////////////////////////////////////////////////////////////////

gulp.task('cp-core', function() {
    return gulp.src(paths.ext_core)
    .pipe(gulp.dest('bin/ext/fire-core'))
    ;
});

gulp.task('cp-engine', function() {
    return gulp.src(paths.ext_engine)
    .pipe(gulp.dest('bin/ext/fire-engine'))
    ;
});

gulp.task('cp-editor-ui', function() {
    return gulp.src(paths.ext_editor_ui)
    .pipe(gulp.dest('bin/ext/fire-editor-ui'))
    ;
});

gulp.task('cp-editor', function() {
    return gulp.src(paths.ext_editor)
    .pipe(gulp.dest('bin/ext/fire-editor'))
    ;
});

gulp.task('cp-misc', function() {
    return gulp.src(paths.editor_misc)
    .pipe(gulp.dest('bin/'))
    ;
});

/////////////////////////////////////////////////////////////////////////////
// clean
/////////////////////////////////////////////////////////////////////////////

gulp.task('clean', function() {
    var files = [
        'bin/package.json',
        'bin/bower.json',
        'bin/favicon.ico',
        'bin/index.html',
        'bin/ext/fire-core/**/*',
        'bin/ext/fire-engine/**/*',
        'bin/ext/fire-editor-ui/**/*',
        'bin/ext/fire-editor/**/*',
    ];
    return gulp.src(files, {read: false})
    .pipe(clean({force: true}))
    ;
});

/////////////////////////////////////////////////////////////////////////////
// tasks
/////////////////////////////////////////////////////////////////////////////

gulp.task('copy', [
    'cp-core', 
    'cp-engine', 
    'cp-editor', 
    'cp-editor-ui',
    'cp-misc',
] );
gulp.task('default', ['copy'] );

gulp.task('watch', function() {
    gulp.watch(paths.ext_core, ['cp-core']).on ( 'error', gutil.log );
    gulp.watch(paths.ext_engine, ['cp-engine']).on ( 'error', gutil.log );
    gulp.watch(paths.ext_editor_ui, ['cp-editor-ui']).on ( 'error', gutil.log );
    gulp.watch(paths.ext_editor, ['cp-editor']).on ( 'error', gutil.log );
});

The log is just:

[12:35:13] Using gulpfile D:\projects\fireball-x\main\gulpfile.js
[12:35:13] Task 'default' is not in your gulpfile
[12:35:13] Please check the documentation for proper gulpfile formatting

My command:

gulp --gulpfile gulpfile.js

@yocontra
Copy link
Member

yocontra commented Sep 5, 2014

So you can see in your log

[12:35:13] Using gulpfile ~/fireball-x/main/gulpfile.js

Which means the --gulpfile flag you say is set to mygulp.js is being ignored

A bug in liftoff on node 0.11? cc @tkellen

@jwu
Copy link
Author

jwu commented Sep 5, 2014

I updated my last comment, here gulpfile.js means mygulp.js. I can rename it and here is the log:

[12:35:13] Using gulpfile D:\projects\fireball-x\main\mygulp.js
[12:35:13] Task 'default' is not in your gulpfile
[12:35:13] Please check the documentation for proper gulpfile formatting

My command:

gulp --gulpfile mygulp.js

@jwu
Copy link
Author

jwu commented Sep 5, 2014

To make things clear, in Windows, with Node v0.11.13, if I running gulp --gulpfile xxx.js, it will give me

[12:35:13] Task 'default' is not in your gulpfile

But if I just run gulp without --gulpfile, things goes well.

@yocontra
Copy link
Member

yocontra commented Sep 5, 2014

@jwu Okay so it isn't the flag that is being ignored

@tkellen
Copy link

tkellen commented Sep 15, 2014

Confirmed bug in Liftoff. I'll have a fix out as soon as I can.

@segrey
Copy link

segrey commented Oct 11, 2014

As a workaround, use lowercased drive letter: --gulpfile=d:\projects\fireball-x\main\mygulp.js
Related bug in WebStrom gulp integration: https://youtrack.jetbrains.com/issue/WEB-13474

@tkellen
Copy link

tkellen commented Oct 14, 2014

Can you run npm update and let me know if this has been resolved?

@jwu
Copy link
Author

jwu commented Oct 16, 2014

Test it in node v0.11.14 + gulp 3.8.8. I failed in Windows' cmd.exe window, but works in git-bash (MinGW terminal).

Here is the snap shot:

In Windows cmd.exe:

cmd_gulp

In Git Bash:

gitbash_gulp

@phated
Copy link
Member

phated commented Nov 16, 2014

pinging @tkellen for an update based on last comment.

@tkellen
Copy link

tkellen commented Nov 18, 2014

Looking into this again now.

@tkellen
Copy link

tkellen commented Dec 1, 2014

Sorry, haven't had time to look at this yet :/. I'm going to need to download a windows vm to fix this, it seems.

@tkellen
Copy link

tkellen commented Dec 22, 2014

If you put a console.log('hello') in mygulp.js, you can see the file is being required properly by gulp.

I believe this has something to do with filename casing and the require cache, the gulp singleton in the gulpfile does not match the gulp singleton in the cli.

I can find a way to fix this, but I think gulpfiles should export their configuration--this global singleton business has always rubbed me the wrong way (#331)

@tkellen
Copy link

tkellen commented Dec 22, 2014

@tkellen
Copy link

tkellen commented Dec 22, 2014

Here is the real root cause: browserify/resolve#61

@phated
Copy link
Member

phated commented Jan 11, 2015

Dug into this a little more. path.join calls path.normalize in node core (see https://github.com/joyent/node/blob/master/lib/path.js#L243) and path.normalize makes windows paths all lowercase (see https://github.com/joyent/node/blob/master/lib/path.js#L181). This is really painful because node's require.resolve method only calls path.resolve which doesn't do any normalization. The resolve module that @tkellen linked to uses path.join a lot.

@phated
Copy link
Member

phated commented Jan 11, 2015

Poking around in the repl, I might have found a solution. The module module of node exposes some internal methods that are used for require.resolve, one of them being module._findPath. I attempted to use this with a cwd and it seemed to work correctly.

var mod = require('module');
var file = mod._findPath('test/gulpfile.js', ['../gulp-cli']);
//=> '/Users/phated/gulp-cli/test/gulpfile.js'

This shouldn't be calling into path.normalize at all but I'd like someone to try it on Windows.

What I really want to know is why they added the toLowerCase to normalize on Windows in node core. It seems insanely broken.

@phated
Copy link
Member

phated commented Jan 11, 2015

Another issue to reference nodejs/node-v0.x-archive#7799

@heikki
Copy link
Contributor

heikki commented Feb 15, 2015

This seems to work with node 0.12.0. @jwu Can you confirm?

screen shot 2015-02-15 at 12 08 16

@jwu
Copy link
Author

jwu commented Feb 16, 2015

I've test node v0.12.0 + gulp latest in Windows. It works! The issue can be closed :)
Thanks a lot.

@tkellen
Copy link

tkellen commented Feb 16, 2015

Thanks heavens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants