gulp icon indicating copy to clipboard operation
gulp copied to clipboard

src() doesn't work with wildcards (4.0.2 -> 5.0.0)

Open lik3as opened this issue 1 year ago • 18 comments

What were you expecting to happen?

all html files in src/html/**/*.html to be in the dist/ directory

What actually happened?

none of the files were in the dist/ dir

Please give us a sample of your gulpfile

gulp.task("build-html", async function () {
  return gulp
    .src("src/html/**/*.html")
    .pipe(
      fileinclude({
        context: layout,
        prefix: "@@",
        basepath: "@file",
        indent: true,
      })
    )
    .pipe(gulp.dest("dist"));
});

Terminal output / screenshots

gulpjs1

$ yarn gulp build-html
$ ls dist/

Please provide the following information:

  • OS & version: Ubuntu 22.04.4 (WSL 2)
  • node version: 22.0.0
  • npm version: 9.6.4
  • gulp version: 5.0.0

Additional information

When using 4.0.2, the program works as expected. So the current solution is downgrading the gulp version.

lik3as avatar Jun 24 '24 15:06 lik3as

i have the same issue its copy part of file

emimoun2 avatar Jun 24 '24 15:06 emimoun2

What happens if you remove async on your function? You can't combine promise-returning and stream-returning functions.

phated avatar Jun 24 '24 16:06 phated

What happens if you remove async on your function? You can't combine promise-returning and stream-returning functions.

this happens: [15:34:34] The following tasks did not complete: build-html [15:34:34] Did you forget to signal async completion? error Command failed with exit code 1.

(i accidentally closed the issue)

lik3as avatar Jun 25 '24 18:06 lik3as

Sounds like your fileinclude plugin is broken, maybe it is emitting an error that's being lost.

Gulp 5 changed the underlying stream implementation and misbehaving stream implementations aren't supported anymore.

phated avatar Jun 25 '24 18:06 phated

I tested and the error still occurs when I remove fileInclude: image

Also, it runs normally when using the callback (but still doesn't include all glob matching files) image

lik3as avatar Jun 25 '24 19:06 lik3as

I have the exact same issue coming from 4.0.2. Using a simple src to dest stream fails with "Did you forget to signal async completion?" when using a wildcard.

Works: gulp.src('src/index.html')

Fails: gulp.src('src/*.html')

redmnat avatar Jul 10 '24 18:07 redmnat

I have the same issue, I started migrating to gulp v5 and faced this.

gulp: v5.0.0
node: v20.14.0
npm: 10.7.0
macOS: 14.6.1 Sonoma

ealcantara22 avatar Aug 29 '24 14:08 ealcantara22

Also getting this with Gulp 5, downgrading to version 4 and it seems to work ok:

yarn add gulp@4

thomjjames avatar Sep 02 '24 12:09 thomjjames

I’m encountering a similar issue with what seems like the simplest, most “basic” task Gulp could be asked to perform. I hate to even bring it up, but....

Working code: gulp.src('src/scss/main.scss')

Failing code: gulp.src('src/scss/**/*.scss')

Yes, that’s right: just a humble attempt to match multiple .scss files in a directory. Is there something that Gulp 5 has against the **/*.scss pattern? This feels so "elemental" that it almost hurts to ask.

Any pointers would be appreciated. I’m really hoping this is just something obvious that I’m overlooking.

vincenzo-antolini-os avatar Nov 05 '24 16:11 vincenzo-antolini-os

Having upgraded from 4.0.2 to 5.0.0, I've also started seeing issues with this minimal Gulp task:

async function copy() {
    return gulp
        .src("wwwroot/lib/library1/folder1/**/*.{ttf}", {
            base: "wwwroot/lib/library1",
        })
        .pipe(gulp.dest("wwwroot/dist"));
}

No files are copied and I triple checked they are in the source folder. If I remove the wildcards and explicity state the folder and file names, it copies over to the dist folder just fine.

Any workarounds that will still allow me to use wildcards?

"npm": "^10.9.2"
node v21.6.0

b-commits avatar Dec 10 '24 12:12 b-commits

I'm having trouble getting this to work after upgrading from gulp 4.0.2 to 5.0.0. The examples in the documentation do not include an async implementation, so they are useless.

[14:02:19] The following tasks did not complete: default
Did you forget to signal async completion?

With this simple task:

const { src, dest } = require('gulp');
const rename = require('gulp-rename');
const sass = require('gulp-sass')(require('sass'));

exports.default = function () {
  return src('./public/src/css/application.scss')
    .pipe(sass({ outputStyle: 'compressed' }))
    .pipe(rename({ extname: '.min.css' }))
    .pipe(dest('public/dist/'));
}

brunnopleffken avatar Dec 10 '24 17:12 brunnopleffken

I'm experiencing the same issue in Gulp 5, even though everything works perfectly in Gulp 4. I can't believe such a basic functionality as wildcards is broken! I spent the entire day debugging my code, only to finally discover this thread and realize I'm not the only one facing this problem. For now, I've reverted back to Gulp 4 until this is resolved.

danielmroczek avatar Feb 14 '25 22:02 danielmroczek

Hi, does anyone know any other workaround other than downgrading? We are intentionally upgrading to address some issues

saul-kaseya avatar May 15 '25 13:05 saul-kaseya

Can anyone experiencing this issue provide details about their environment? The bare minimum when reporting bugs like this are your node version, output of npm ls, gulpfile code, etc.? This isn't something anyone can reproduce easily (otherwise we would be seeing thousands and thousands of reports, everyone uses gulp.src with globs) and there hasn't been a common denominator sent in so far with all of these comments. Seriously the "wtf?? how is something so basic broken???" comments are just a waste of space in these threads and distract from the actual problem solving some of us need to do.

So far it seems like this has been seen on:

  • Ubuntu 22.04.4 (WSL 2) with node 22
  • macos 14 with node 20

yocontra avatar Jun 01 '25 01:06 yocontra

I believe this was related to https://github.com/gulpjs/glob-stream/pull/136 which we've fixed in https://github.com/gulpjs/gulp/pull/2839 and released as gulp v5.0.1

Can you please upgrade and test it out?

phated avatar Jun 01 '25 21:06 phated

Same thing, simplest src-to-dest example task crash on a glob with a wildcard, doesn't crash on a singular glob.

node v14.21.3 npm v6.14.18

And yes, @phated, I'm still seeing this on gulp v5.0.1.

tedmx avatar Jun 05 '25 08:06 tedmx

Following advice by @yocontra not to wtf and rather to be constructive, I've played with my gulpfile, removing stuff until the issue goes away, and found the culprit.

After I comment cssmin = require('gulp-cssmin') , the issue goes away. Meaning that simple act of requiring gulp-cssmin breaks gulp.

My gulp-cssmin is v0.1.7. Updating gulp-cssmin to v0.2.0, it's "latest" version, doesn't help, the issue persists.

Additionally, this package is in somewhat broken state, check out its page on npm https://www.npmjs.com/package/gulp-cssmin. Link to github https://github.com/chilijung/gulp-cssmin gives you 404. Funnily enough there is another gulp-cssmin on github https://github.com/pdehaan/gulp-cssmin with same @chilijung in contributors list, but it doesn't have v0.2.0 version which is listed on npm.

So, all affected people should try to remove gulp-cssmin from gulpfile and see if the issue persists.

tedmx avatar Jun 05 '25 10:06 tedmx

Next I tried gulp-clean-css as a substitute for gulp-cssmin. Seems to work good, it does its minifying job. In addition to that, the substitution was seamless, gulp-clean-css accepted the same very options that my gulp-cssmin used.

tedmx avatar Jun 06 '25 09:06 tedmx