question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

gulp.dest uses chmod on files

See original GitHub issue

When I pipe my compiled css into gulp.dest(folder) it will fail with an error:

events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: EPERM, chmod 'css/screen.css'

This is because screen.css already exits and only gets overriden - however the user running gulp isn’t the owner of the file.

This is a bug since according to the documentation chmod gets applied to new folders only: options.mode - Octal permission string specifying mode for any folders that need to be created for output folder.

Code:

var gulp = require('gulp');
var sass = require('gulp-sass');
gulp.task('default', function() {
    gulp.src(sassUri + '**/*.{scss,sass}')
        .pipe(sass())
        .pipe(gulp.dest('css'));
});

PS: If this isn’t a bug but a feature, how can I turn this off (or handle it properly)?

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:4
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
hashworkscommented, Apr 11, 2015

Yeah, I understand how chmod works on GNU/Linux. But on my systems gulp can and will by run by many different users (which are in the same group, though). IMO gulp has absolutely no need to run chmod on this file, since he only needs to write to it.

If I’m unable to turn of this feature I’m absolute ok with catching and ignoring it - my only intention is that the watcher doesn’t fail because of this. Could you show me an example how to catch this error?

0reactions
yocontracommented, Apr 15, 2015

@hashworks There was a bug with the chmod stuff in 3.x - feel free to use the 4.0 stuff it’s stable, just waiting on a few more issues to land before we publish

Read more comments on GitHub >

github_iconTop Results From Across the Web

Gulp - Handle read-only permissions for dest files?
You can use gulp-chmod to handle permissions on your files. So if you want to set your images readable and writable for everybody,...
Read more >
gulp-chmod - npm
Change permissions of Vinyl files. ... Start using gulp-chmod in your project by running `npm i gulp-chmod`. ... gulp.src('src/app.js').
Read more >
dest() - gulp.js
Creates a stream for writing Vinyl objects to the file system. ... If a function is used, the function will be called with...
Read more >
Gulp-chmod NPM - npm.io
Specify true to use the same value as fileMode . Tip. Combine it with gulp-filter to only change permissions on a subset of...
Read more >
JavaScript gulp-chmod Examples - HotExamples
gulp.task('copy-styles', function() { return merge( gulp.src(config.files.vendor.css) .pipe(chmod(644)) .pipe(gulp.dest(dist_dir + '/assets/css')), ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found