amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

gulp dist fails on Windows

Open sveronesi opened this issue 7 years ago • 6 comments

What's the issue?

gulp dist fails on Windows because it fails to create sub directories

The issue is that 'gulp-closure-compiler' uses 'graceful-fs' which is not capable of recursively create subdirectories in Windows I was able to workaround the issue by manually editing node_modules/gulp-closure-compiler.js.

Code sample File: node_modules/gulp-closure-compiler.js // Create directory for output file if it doesn't exist. if (opt.fileName && !fs.existsSync(path.dirname(opt.fileName))) { fs.mkdirSync(path.dirname(opt.fileName)); }

I modified the code to use mkdirp directly: // Create directory for output file if it doesn't exist. if (opt.fileName && !fs.existsSync(path.dirname(opt.fileName))) { mkdirp(path.dirname(opt.fileName)); }

Error message fs.js:1**14 throw err; ^

Error: ENOENT: no such file or directory, mkdir 'build/cc/ads\inabox' at Object.mkdirSync (fs.js:752:3) at Stream.endStream (c:\src\amphtml\node_modules\gulp-closure-compiler\index.js:110:10) at _end (c:\src\amphtml\node_modules\through\index.js:65:9) at Stream.stream.end (c:\src\amphtml\node_modules\through\index.js:74:5) at DestroyableTransform.onend (c:\src\amphtml\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:523:10) at Object.onceWrapper (events.js:277:13) at DestroyableTransform.emit (events.js:194:15) at c:\src\amphtml\node_modules\vinyl-fs\node_modules\readable-stream\lib_stream_readable.js:965:16 at process._tickCallback (internal/process/next_tick.js:61:11)**

How do we reproduce the issue?

1 - Setup a Windows machine following: https://github.com/ampproject/amphtml/blob/master/contributing/getting-started-e2e.md 2 - Build: gulp dist

What browsers are affected?

N/A

Which AMP version is affected?

master

sveronesi avatar Apr 12 '19 07:04 sveronesi

/to @rsimha

aghassemi avatar Apr 16 '19 01:04 aghassemi

I tried rolling back to a version that doesn't use graceful-fs. Unfortunately, gulp-closure-compiler has stopped publishing updates, and has gone so far as to delete their open source repo: https://www.npmjs.com/package/gulp-closure-compiler

@erwinmombay Is there any reason we need to use gulp-closure-compiler? (Do we use it only to support gulp.src?)

https://github.com/ampproject/amphtml/blob/680dd188e47114af397083500333a7ab0ddd886e/build-system/tasks/compile.js#L423-L431

If so, do you think we should try switching away from it and directly stream the output of gulp.src to our closure compiler runner? (Assuming it's possible.)

rsimha avatar Apr 16 '19 01:04 rsimha

@ssantosms Good news. I'm working on a way to discontinue the use of gulp-closure-compiler and switch to the use of the native gulp plugin that's a part of google-closure-compiler. This is coming up in #21868.

After this is done, I'd imagine this issue should go away on its own. Stay tuned!

rsimha avatar Apr 16 '19 05:04 rsimha

@ssantosms The dependency on gulp-closure-compiler has been removed. Let us know if this solved the problem for you.

rsimha avatar Apr 17 '19 01:04 rsimha

Thanks @rsimha

sveronesi avatar Apr 17 '19 23:04 sveronesi

Reopening because #21868 had to be reverted. New fix coming up in #21900

rsimha avatar Apr 18 '19 07:04 rsimha