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.

Error: EPERM: operation not permitted, chmod

See original GitHub issue

image

const gulp = require('gulp');
const sass = require('gulp-sass');
const csso = require('gulp-csso');
const autoprefixer = require('gulp-autoprefixer');
const uglify = require('gulp-uglify');
const addsrc = require('gulp-add-src');
const concat = require('gulp-concat');
const imageResize = require('gulp-image-resize');

const targetDir = 'dist';

gulp.task('default', ['sass', 'js', 'thumbnails']);

gulp.task('sass', () => {
    return gulp.src('src/scss/**/*.scss')
        .pipe(sass().on('error', sass.logError))
        .pipe(addsrc('src/css/**/*.css'))
        .pipe(autoprefixer())
        .pipe(csso())
        .pipe(concat('style.css'))
        .pipe(gulp.dest(targetDir))
});

// (...)

What’s wrong that gulp sass doesn’t have permissions to write to dist/style.css when current user is in group that is owner of this file?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

4reactions
ahmedelboughacommented, Jun 11, 2019

Actually, it’s a Linux issue not a gulp issue. The problem is that only the owner of a file or root users can change the permissions of of a file, but group users are not allowed to do so. The solution that I did to fix this problem is to change the owner of the file in following way: chown myuser:http . -R Of course with keeping permissions as 775 or 755. This way Apache user (as group user) is still allowed to run/read the files and my user is allowed to run glup command with tasks including chmod.

2reactions
lustosacommented, Jan 28, 2021

@jorismak exactly. gulp shouldn’t be attempting to chmod anything, it’s not its purpose. As a very dirty workaround, I’ve been using the code below for the past few years. Just put it somewhere in the gulpfile, and it should bypass the actual chmod call:

const fs = require(‘fs’)

if (1) { fs.chmod = (a, b, cb) => cb(0) }

Read more comments on GitHub >

github_iconTop Results From Across the Web

EPERM: operation not permitted, chmod · Issue #3699 - GitHub
I had an issue where mkdirp@1.0.4/node_modules/mkdirp/bin/cmd.js ended up with root:wheel ownership. That caused me to get ERROR EPERM: ...
Read more >
Using gulp with a team on a Local Server. Error: EPERM
I have tried using chmod to change the file permissions but I don't think that is the issue. I use atom as my...
Read more >
Gulp returns error: EPERM: operation not permitted, chmod ...
I was working on a script that updated sitemap.xml in the public directory and to do this, it needed permission for writing to...
Read more >
Operation not permitted - Justin Webb - Medium
This error tells you that your system could not access and mutate the permission to a file system needed to complete your command....
Read more >
Error: EPERM: operation not permit… | Apple Developer Forums
I am installing packages for NODEJS/NPM and am receiving the following error, which, apparently, is not an error with the software, but with...
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