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

Remote drive: Execute permission removed from file on save when saving #12309

Closed
PunchyRascal opened this issue Sep 20, 2016 · 16 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug file-explorer Explorer widget issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Milestone

Comments

@PunchyRascal
Copy link

  • VSCode Version: Code 1.5.2 (66f37fd, 2016-09-12T13:30:03.456Z)
  • OS Version: Windows_NT ia32 10.0.14393

Steps to Reproduce:

  1. have a file on a remote drive that has execute permission on underlying linux system
-rwxr-xr-x  1 frantisek frantisek  2131 Sep 20 09:26 wo
  1. edit the file in vs code, save
  2. file now lacks execute permission for user:
-rw-r-xr-x  1 frantisek frantisek  2131 Sep 20 09:26 wo
@chrmarti chrmarti added the bug Issue identified by VS Code Team member as probable bug label Sep 20, 2016
@chrmarti
Copy link
Collaborator

Reproduced with a Windows VM on OSX editing a file that is on the OSX filesystem. There the permissions go from -rwxr-xr-x to -rw-r--r-- after saving. The Finder shows a new creation date.

Saving the file with VSCode on OSX does not change the permissions and the Finder shows the old creation date.

@joaomoreno joaomoreno assigned bpasero and unassigned joaomoreno Sep 21, 2016
@bpasero
Copy link
Member

bpasero commented Sep 21, 2016

Upstream issue which very likely reproduces with bare node.js too.

@bpasero bpasero added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Sep 21, 2016
@bpasero bpasero added this to the Backlog milestone Sep 21, 2016
@bpasero
Copy link
Member

bpasero commented Sep 21, 2016

@PunchyRascal @chrmarti if you can write a node.js script which runs fs.writeFile to the remote file to see if that changes the executable bits? If so, my assumption would be right.

@PunchyRascal
Copy link
Author

PunchyRascal commented Sep 21, 2016

EDIT: this is about appendFile, not writeFile


Nope, running the following code, where foo.txt is on the remote drive:

const fs = require('fs');
fs.appendFile('z:/foo.txt', 'data to append2', (err) => {
  if (err) throw err;
  console.log('The "data to append" was appended to file!');
});

does not remove the execute permission. The data is written to the file.

@PunchyRascal
Copy link
Author

PunchyRascal commented Sep 21, 2016

Sorry, I used appendFile instead of writeFile. Append works fine, as mentioned before, write indeed removes the executable permission.

@bpasero
Copy link
Member

bpasero commented Sep 21, 2016

@PunchyRascal please report this to node.js then.

@bpasero
Copy link
Member

bpasero commented Sep 21, 2016

@PunchyRascal maybe you first try our insider build which comes with a much newer node.js release (6.3.0):
You can give our preview releases a try from: http://code.visualstudio.com/Download#insiders

@PunchyRascal
Copy link
Author

(just a technical note, the link seems to be http://code.visualstudio.com/insiders)

@PunchyRascal
Copy link
Author

Nope, still there. Anyway I reproduced this even with a script running on node 6.6.

However, there seem to be some shenanigans concerning the file permission, see nodejs/node-v0.x-archive#25756

I can't really tell if what they say there solves this issue ATM.

@chrmarti
Copy link
Collaborator

Same here. I found the following preserves the permissions (and possibly other metadata):

const fs = require('fs');
const fd = fs.openSync('script.sh', 'r+');
fs.ftruncateSync(fd, 0);
fs.writeSync(fd, '#!/bin/bash\n\necho yay!\n');
fs.closeSync(fd);

@bpasero
Copy link
Member

bpasero commented Sep 21, 2016

@chrmarti but did you try going through the remote drive to see if it preserves executable bit there too?

@chrmarti
Copy link
Collaborator

@bpasero I ran that code in my Windows VM with a workspace that is on the host OSX filesystem. On OSX ls -l would show the executable bits set before and after. writeFile() would loose them.

There are no attributes shown when looking at the file from the Windows VM's file explorer (if that's what you're referring to).

@bpasero
Copy link
Member

bpasero commented Sep 22, 2016

Ok, going via fs.write might be an option to workaround this. I still think that writeFile could be better though so I encourage to file an issue against node.js itself 👍

@bpasero bpasero changed the title Execute permission removed from file on save Remote drive: Execute permission removed from file on save when saving Sep 22, 2016
@bpasero bpasero added help wanted Issues identified as good community contribution opportunities and removed help wanted Issues identified as good community contribution opportunities labels Oct 31, 2016
@bpasero
Copy link
Member

bpasero commented Oct 31, 2016

I filed nodejs/node#9380

Actually it works also for fs.writeFile but you need to run with r+ as mode. I am not sure why though...

@PunchyRascal
Copy link
Author

I don't know what happened, but don't experience this issue anymore. Executable files seem to keep their x right.

@bpasero
Copy link
Member

bpasero commented Jan 3, 2017

Weird, I do not recall any change in this area for a while.

@bpasero bpasero added workbench file-explorer Explorer widget issues and removed workbench labels Apr 7, 2017
@bpasero bpasero closed this as completed Apr 10, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug file-explorer Explorer widget issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

4 participants