-
Notifications
You must be signed in to change notification settings - Fork 28.2k
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
'Retry As Sudo' doesn't work to save a file #70403
Comments
(Experimental duplicate detection) |
File is not read-only and is writeable by root so that issue is not relevant. |
@lord-soth does it work if you do not do that?
|
@bpasero It doesn't work also if I change it to: I can save if I start VSCode with superuser privilages but that is expected. |
@lord-soth can you see if something is printed to the console when this happens? You can see output when you run with "code --verbose" and open the developer tools from the help menu @jorangreef any hints what this could be? We are still using |
@bpasero I think the relevant part is:
|
@lord-soth yeah that is the first part of the error which is to be expected because this triggers the prompt to save as admin. I you are up to it, can you try to reproduce just using the https://github.com/jorangreef/sudo-prompt module? This is what VSCode is using after all. |
@bpasero I checked that the sudo-prompt node package is not installed so I installed it.
I executed test.js provided by sudo-prompt package to make sure sudo-prompt works correctly. Password prompt appeared and I entered my password. It seems to work.
I executed
However there is no change in VSCode. I don't know how VSCode uses sudo-prompt so I can't investigate the issue. Also I have no experience with NodeJs or Electron so I don't think I can debug by myself. |
@lord-soth ok, there is more things we can try. If you tell VSCode to save as sudo, the following will happen:
It is possible that this fails, maybe you could change your script to exercise the same things? |
@bpasero I don't have the time and don't have the java/js experience(I am a c++ dev) to debug this but if you give me a script/executable to run I can try. Maybe in the near future I can try to debug. |
Thanks @lord-soth for running the If that passes, then I don't think it's anything specific to your Arch Linux system or your sudoers file. @bpasero , thanks for the heads up. I will keep tabs on this and will still look into the |
@lord-soth in your script, just try this:
And see if that works or throws an error. @jorangreef thanks, I would assume this is probably specific to @lord-soth configuration as I have not heard any issues from any other users so far. |
|
@lord-soth sorry, you need to require the module too: |
|
@lord-soth we are getting there :). Can you:
package.json: {
"name": "name",
"description": "description",
"authors": "author",
"version": "1.0.0",
"main": "pathToMain",
"dependencies": {
"sudo-prompt": "8.2.5"
}
} |
@bpasero |
@lord-soth ok and does it actually write the file properly? can you check? |
@bpasero |
@lord-soth sorry, this will actually only work if the file exists, I just realize. So please try again with a target file that exists too. |
@bpasero I created the file. It doesn't write, size is 0. |
@lord-soth does it print anyoutput when you use "code --verbose" instead of just "code" in your script. |
@bpasero No, adding --verbose doesn't print any output. |
@lord-soth is something printed if you just literally run |
|
If |
@lord-soth just to double check: there are a few assumptions in VSCode to make the I wonder if |
@bpasero Below you can see that I am doing what you want me to do. I copied it from the terminal without modifying the order:
You can see that httpd.conf file size is 20377 but size of test file remains 0. |
@lord-soth, just a nit: The binary path passed to i.e. You should provide the full path to the I am not sure if that's the cause of this, but that will help you avoid shadowing issues. |
@jorangreef Changed |
Thanks @lord-soth Can you try another version of your |
@jorangreef No problem. I created a new script:
It correctly copies httpd.conf to test without any output at terminal. |
It seems that $ stat /tmp/sudotest/index.js
File: /tmp/sudotest/index.js
Size: 281 Blocks: 8 IO Block: 4096 regular file
Device: 2dh/45d Inode: 191907 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ rocka) Gid: ( 1000/ rocka)
Access: 2019-03-27 13:48:06.713222257 +0800
Modify: 2019-03-27 13:48:37.976633050 +0800
Change: 2019-03-27 13:48:37.976633050 +0800
Birth: -
$ stat /tmp/a.js
stat: cannot stat '/tmp/a.js': No such file or directory
$ ./code --file-write /tmp/sudotest/index.js /tmp/a.js
Using --file-write with invalid arguments.
$ ./code --file-write /tmp/a.js /tmp/sudotest/index.js
Using --file-write with invalid arguments.
$ ./code --file-write
Using --file-write with invalid arguments. Maybe it has something to do with argv parsing issues? OS and VSCode versions: $ uname -sr
Linux 5.0.4-arch1-1-ARCH
$ ./code --version
1.32.3
a3db5be9b5c6ba46bb7555ec5d60178ecc2eaae4
x64 VSCode was downloaded from https://code.visualstudio.com/#alt-downloads Linux .tar.gz 64 bit version. That |
@rocka both source and target have to exist and have to be absolute file paths |
@bpasero Sorry for that mistake ... then I got some test again: $ sudo ./code --verbose --file-write /tmp/sudotest/index.js /tmp/a.js
Error using --file-write: EACCES: permission denied, open '/tmp/a.js'
$ pkexec $PWD/code --verbose --file-write /tmp/sudotest/index.js /tmp/a.js
Error using --file-write: EACCES: permission denied, open '/tmp/a.js'
$ ./code --verbose --file-write /tmp/sudotest/index.js /tmp/a.js
(works as expected)
$ su root
Password:
# ./code --verbose --file-write /tmp/sudotest/index.js /tmp/a.js
Error using --file-write: EACCES: permission denied, open '/tmp/a.js' According to |
@rocka if using sudo still results in a permission denied error than this hardly sounds like an issue with VSCode but rather the configuration of the OS and file system, no? Does it work if you use vi or any other editor with sudo? |
@bpasero Oh yes... Only file in I'm sorry for such a mistake ... I think this should be a problem with package |
Oh wow this is Arch Linux, yeah likely. |
@bpasero So what is the solution |
@lord-soth download vscode binary at https://code.visualstudio.com/#alt-downloads or just install https://aur.archlinux.org/packages/visual-studio-code-bin/ |
Why is it that the |
@h1nk The feature works fine if you install vscode via Microsoft official repo mentioned in #2973 (comment) As for Arch Linux's pacman repo, it's a packaging issue: https://bugs.archlinux.org/task/61516 |
@rocka I've installed |
@h1nk If so I think you should open a new issue, it works fine on my machine ... |
Steps to Reproduce:
When I try to edit and save a file with root permissions a prompt appears saying Failed to save httpd.conf. Insufficient permissions. Select Retry as Sudo to retry as superuser. When I click Retry as Sudo button same prompt reappears and file isn't saved. Prompt reappears every time I click the button.
I don't know if its relevant but I edited my sudoers file so sudo doesn't ask me for password:
alp ALL=(ALL) NOPASSWD: ALL
Does this issue occur when all extensions are disabled?: Yes
The text was updated successfully, but these errors were encountered: