nicosantangelo / sublime-gulp

Run Gulp tasks and use snippets from Sublime Text
https://sublime-gulp.nicosantangelo.com/
MIT License
155 stars 18 forks source link

There was an error running gulp, make sure gulp is running correctly in your project #67

Closed ghost closed 8 years ago

ghost commented 8 years ago

Hi!

I' ve got this error when starting gulp in sublime.

This is my log file:

TypeError: path must be a string at TypeError (native) at Object.fs.openSync (fs.js:584:18) at Object.fs.readFileSync (fs.js:431:33) at requireGulp (C:\Users\Family\AppData\Roaming\Sublime Text 3\Packages\Gulp\write_tasks_to_cache.js:24:22) at Object. (C:\Users\Family\AppData\Roaming\Sublime Text 3\Packages\Gulp\write_tasks_to_cache.js:83:12) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10)

07-14-2016 00:35: fs.js:584 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^

TypeError: path must be a string at TypeError (native) at Object.fs.openSync (fs.js:584:18) at Object.fs.readFileSync (fs.js:431:33) at requireGulp (C:\Users\Family\AppData\Roaming\Sublime Text 3\Packages\Gulp\write_tasks_to_cache.js:24:22) at Object. (C:\Users\Family\AppData\Roaming\Sublime Text 3\Packages\Gulp\write_tasks_to_cache.js:83:12) at Module._compile (module.js:413:34) at Object.Module._extensions..js (module.js:422:10) at Module.load (module.js:357:32) at Function.Module._load (module.js:314:12) at Function.Module.runMain (module.js:447:10)

nicosantangelo commented 8 years ago

Hello!

That's weird, looks like the script that handles writing the cache could not find the gulpfile.js

Just to see if I can reproduce this, how is your project structured and which folder is included in sublime? The gulpfile.js is at the root of the project and at the root on Sublime (in the sidebar) ?

Also, do you happen to see a .sublime-gulp-tmp.js file in your project ?

Thanks!

ghost commented 8 years ago

Hello!

Actually I tried very simple different projects just to test gulp in sublime. The gulpfile.js is in the root of the project and in the sidebar of sublime. Also gulp is installed global and locally.

Thanks a lot!

nicosantangelo commented 8 years ago

ok, let's try this, can you run node in the project root and input the following ?

$ node
var cwd = process.cwd()
var cachePath    = path.join(cwd, ".sublime-gulp.cache");
var tmpfilePath  = path.join(cwd, ".sublime-gulp-tmp.js");
var gulpfilePath = (function() {
    var allowedExtensions = [".babel.js", ".js"];
    for(var i = 0; i < allowedExtensions.length; i++) {
        var filepath = path.join(cwd, "gulpfile" + allowedExtensions[i]);
        if (fs.existsSync(filepath)) {
            return filepath;
        }
    }
})();

console.log("The gulpfilePath is", gulpfilePath)

var fileSrc = fs.readFileSync(gulpfilePath);

console.log("The fileSrc is (buffer)", fileSrc)

That's part of the source that creates the gulp cache for the package, and that's failing in your machine (but normally works)

ghost commented 8 years ago

Ok. Done. Here it is the result printscreen: try01

nicosantangelo commented 8 years ago

Oh I was expecting an error. That piece of code you ran is the exact same that the one is breaking on the package. The error TypeError: path must be a string comes from fs.readFileSync at requireGulp which does:

var requireGulp = function(gulpfilePath) {
    var fileSrc = fs.readFileSync(gulpfilePath);
    // ...

The only thing I can think of right now is that there might be a problem with permissions?, it looks like: . When sublime runs that code, process.cwd() is returning undefined (or something invalid) . Or, fs.existsSync(filepath) can't find the file across partitions

Do you know if there is anything strange with the read access?

(thanks for taking the time with the follow up)

ghost commented 8 years ago

Yeah, gotcha! The problem was in my cmd reg settings.

I had HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\AutoRun configured with cd /d c:\ value. It means that my default cmd path was changed to c:\. I cleared the value and now all is running correctly.

Thank you very much for the help.

nicosantangelo commented 8 years ago

Wohooo!

You're welcome, thanks for letting me know!