Giter Site home page Giter Site logo

Comments (14)

kevva avatar kevva commented on May 30, 2024

You have to write the file to a destination using gulp.dest().

from gulp-chown.

LexLythius avatar LexLythius commented on May 30, 2024

Yes, that's what I tried in the first place, but for some reason it didn't put the files with modified permissions, it just left them unchanged. o_O

from gulp-chown.

LexLythius avatar LexLythius commented on May 30, 2024

For example, having:

# ls -la
total 24
drwxrwxr-x 5 www-data www-data 4096 may 19 14:23 .
drwxr-xr-x 6 root     root     4096 may 18 16:32 ..
dr-xrws--- 2 root     root     4096 may 19 14:23 css
-rw-r--r-- 1 lisandro www-data 3740 may 19 14:43 index.html
dr-xrws--- 2 root     root     4096 may 19 14:23 js
dr-xrws--- 5 root     root     4096 may 19 14:23 lib

and

gulp.task('default', function () {
    gulp.src(paths.deploy + '/index.html')
            .pipe(chown('lisandro', 'adm'))
            .pipe(chmod(755))
            .pipe(gulp.dest(paths.deploy))
            ;
});

I run

# gulp
[14:43:27] Using gulpfile /home/lisandro/Blink/repo-nuevo/blink-v2-spa/gulpfile.js
[14:43:27] Starting 'default'...
[14:43:27] Finished 'default' after 4.46 ms

and get

# ls -la
total 24
drwxrwxr-x 5 www-data www-data 4096 may 19 14:23 .
drwxr-xr-x 6 root     root     4096 may 18 16:32 ..
dr-xrws--- 2 root     root     4096 may 19 14:23 css
-rwxr-xr-x 1 lisandro www-data 3740 may 19 14:46 index.html
dr-xrws--- 2 root     root     4096 may 19 14:23 js
dr-xrws--- 5 root     root     4096 may 19 14:23 lib

As you can see, chmod works but chown doesn't.
Using chown without chmod makes no difference.

Using Ubuntu 14.04.2 LTS x86_64, Node.js v0.10.25.

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

Is this issue solved? I'm having the same issue. I can chmod just fine but chown doesn't work. I am using gulp.dest as well. When overwriting the same file nothing happens, and when putting it in a new directory it's set to root:root (running as root.)

from gulp-chown.

LexLythius avatar LexLythius commented on May 30, 2024

I now think this is actually a bug with dest ignoring chown's metadata, not a bug with chown itself.

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

I ran some tests (modified chown to console.log its intended permissions) and confirmed chown is doing its job, and the problem is with dest.

from gulp-chown.

sindresorhus avatar sindresorhus commented on May 30, 2024

Best way forward would be to submit a failing test here: https://github.com/wearefractal/vinyl-fs

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

I'm working on making the required changes to vinyl-fs and submitting them. But I'd love if someone also did what @sindresorhus suggested (I haven't worked with vinyl-fs before.)

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

After running more tests, it seems that chown is setting the correct uid and gid (33:33 in my case,) but that dest is receiving the current one (1000:1000 in my case.) This could be a deeper problem.

from gulp-chown.

LexLythius avatar LexLythius commented on May 30, 2024

Probably a matter of mixing effective and real user IDs.

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

This is very strange - I just commented out .pipe(chmod(770)) in my pipeline and it successfully chowned the files. Working on figuring out why.

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

OK - a crude fix:
Adding fs.chown(writePath, file.stat.uid, file.stat.gid, function(){}); at the end of the fs.stat call in the written function in vinyl-fs/lib/dest/writeContents/index.js (line 31 for me) fixes it, but only if you don't also use gulp-chmod.
This obviously is a terrible fix (no error handling, breaks gulp-chmod, etc.) but it's the beginning of a solution.
The main problem now is that the done (or complete, depends on vinyl-fs version) callback can't be used by both fs.chmos and fs.chown.

from gulp-chown.

c0d3rman avatar c0d3rman commented on May 30, 2024

Until this issue is fixed (by the vinyl-fs people), I am using a clone I made of gulp-chown that just fs.chowns the files instead of setting file.stats.uid and file.stats.gid. Not ideal, but it works.

from gulp-chown.

 avatar commented on May 30, 2024

Best way forward would be to submit a failing test here: https://github.com/wearefractal/vinyl-fs

Iiuc (?), this is the relevant issue @ vinyl-fs proj

	Support changing uid/gid from the vinyl object to the file on disk
	 https://github.com/gulpjs/vinyl-fs/issues/157

which looks like it's got a commited fix @master

	https://github.com/gulpjs/vinyl-fs/commit/9fd1689182314c78dabe5b2fd426a17738265b5b

After installing

	yarn add --dev https://github.com/gulpjs/vinyl-fs.git#master

This task,

	export function scss_strip() {
		return pump([
			gulp.src([
				'./assets/gen/css/min/frontpage.min.css'
			]),
			stripCssComments({ preserve: false}),
			chown('wwwrun','www'),
			gulp.dest( './web/css/' )
		])
		;
	};

, run as root, does create the dest file, but ignores the chown; file's still created as root:root.

I understand this^ is old -- from 2015 -- but it is still open ...

What am I missing in the config/usage? Or, has the fix gone elsewhere?

from gulp-chown.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.