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

Gulp.src glob pattern fails in various edge situations #128

Closed
4 tasks done
proton-ab opened this issue Apr 6, 2024 · 3 comments
Closed
4 tasks done

Gulp.src glob pattern fails in various edge situations #128

proton-ab opened this issue Apr 6, 2024 · 3 comments

Comments

@proton-ab
Copy link

proton-ab commented Apr 6, 2024

Before you open this issue, please complete the following tasks:

  • use the search bar at the top of the page to search this repository for similar issues or discussions that have already been opened.
  • if you are looking for help from the gulp team or community, open a discussion.
  • if you think there is a problem with the plugin you're using, open a discussion.
  • if you think there is a bug in our code, open this issue.

What were you expecting to happen?

Gulp.src works as it did previously in v4, ignoring directories and files outside of scope of patterns provided. No error is raised.

What actually happened?

Gulp.src scans entire directory tree and fails on at least these cases:

  • Another process runs in different sub-directory that creates and removes temporary files
  • Broken or invalid link is encountered

Please give us a sample of your gulpfile

import path from 'path';
import os from 'os';

// Gulp specific
import Gulp from 'gulp';

const dirs = {
  tmp: path.join(os.tmpdir(), 'gulp-build-cache'),
  out: 'public/static',
};

// ---

function hash() {
  return Gulp.src(`${dirs.tmp}/**/*.*`)
    .pipe(Gulp.dest(dirs.out))
}

// ---

function css() {
  return Gulp.src('assets/public/**/*.css')
    .pipe(Gulp.dest(dirs.tmp));
}

// ---

export const build = Gulp.series(css, hash);

Terminal output / screenshots

vagrant@debian11:/code$ yarn gulp build
yarn run v1.22.22
$ node ./node_modules/gulp/bin/gulp.js build
[16:26:34] Using gulpfile /code/gulpfile.mjs
[16:26:34] Starting 'build'...
[16:26:34] Starting 'css'...
[16:26:40] Finished 'css' after 6.07 s
[16:26:40] Starting 'hash'...
[16:26:42] 'hash' errored after 2.12 s
[16:26:42] Error: ENOENT: no such file or directory, scandir '/code/vendor/dflydev/fig-cookies'
[16:26:42] 'build' errored after 8.2 s
vagrant@debian11:/code$ yarn gulp build
yarn run v1.22.22
$ node ./node_modules/gulp/bin/gulp.js build
[16:31:32] Using gulpfile /code/gulpfile.mjs
[16:31:32] Starting 'build'...
[16:31:32] Starting 'css'...
[16:31:32] 'css' errored after 20 ms
[16:31:32] Error: ENOENT: no such file or directory, stat '/code/scripts'
[16:31:32] 'build' errored after 23 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
vagrant@debian11:/code$ ls -l /code/scripts
lrwxrwxr-x 1 vagrant www-data 0 Oct 29  2021 /code/scripts -> ../calamari/scripts

Please provide the following information:

  • OS & version [e.g. MacOS Catalina 10.15.4]: Debian GNU/Linux 11
  • node version (run node -v): v18.20.1
  • npm version (run npm -v): 10.5.0
  • gulp version (run gulp -v): 5.0.0 (CLI 3.0.0)

Additional information

The first terminal output is result of running composer in parallel with gulp. Second one is result of placing broken link in directory tree (the link becomes valid later on, but is not at the time gulp is being run). The issue seems related to #129 but is different enough that I believe it warrants raising separate issue.

@yocontra yocontra transferred this issue from gulpjs/gulp Apr 6, 2024
@phated
Copy link
Member

phated commented Apr 8, 2024

@proton-ab can you try out 8.0.2 and open more concise issues for anything that still has problems? Thanks 🙏

@proton-ab
Copy link
Author

Will try in a moment and report back.

I still need to look into #128 because the issue isn't clear on what paths don't work, as the only error seems to indicate an absolute path outside of the cwd.

Sorry, I had to redact path in the first error message and might've caused confusion. I've adjusted it to be a absolute path as that seems to be what error message always produces. cwd of gulp in this case is /code. Assuming that you no longer walk entire cwd tree then this should be resolved as Gulpfile only globs on /code/assets/**.

@proton-ab
Copy link
Author

Can confirm v8.0.2 is not susceptible to any of the two edge cases from the issue. Thank you for quick fix.

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

No branches or pull requests

2 participants