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

VSCode-linux-x64-stable.zip doesn't run as root #5679

Closed
ctaggart opened this issue Apr 22, 2016 · 10 comments
Closed

VSCode-linux-x64-stable.zip doesn't run as root #5679

ctaggart opened this issue Apr 22, 2016 · 10 comments
Assignees
Labels
install-update VS Code installation and upgrade system issues linux Issues with VS Code on Linux
Milestone

Comments

@ctaggart
Copy link

Steps to Reproduce:

curl -o VSCode-linux-x64-stable.zip -L https://go.microsoft.com/fwlink/?LinkID=620884
unzip -q VSCode-linux-x64-stable.zip
export PATH=$PWD/VSCode-linux-x64:$PATH
code --verbose
root@937050988adf:~# code --verbose
{ [Error: ENOENT: no such file or directory, open '/root/.config/Code/storage.json']
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/root/.config/Code/storage.json' }
TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:274:26)
    at Object.exports.spawn (child_process.js:351:9)
    at /root/VSCode-linux-x64/resources/app/out/vs/workbench/electron-main/main.js:6:6784
    at new __dirname.undefined.t.Class.derive._oncancel (/root/VSCode-linux-x64/resources/app/out/vs/workbench/electron-main/main.js:5:6601)
    at Object.i [as getUserEnvironment] (/root/VSCode-linux-x64/resources/app/out/vs/workbench/electron-main/main.js:6:6747)
    at Object.<anonymous> (/root/VSCode-linux-x64/resources/app/out/vs/workbench/electron-main/main.js:9:10764)
    at e._invokeFactory (/root/VSCode-linux-x64/resources/app/out/vs/loader.js:4:13697)
    at e._complete (/root/VSCode-linux-x64/resources/app/out/vs/loader.js:4:14014)
    at e.resolveDependency (/root/VSCode-linux-x64/resources/app/out/vs/loader.js:4:15068)
@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug install-update VS Code installation and upgrade system issues linux Issues with VS Code on Linux labels Apr 22, 2016
@Tyriar Tyriar self-assigned this Apr 22, 2016
@Tyriar
Copy link
Member

Tyriar commented Apr 22, 2016

@ctaggart haven't seen this before. I'm curious who owns files/folders, what the permissions are on them and whether they actually exist. Can you pass along the output of these commands?

whoami
ls -la ~ | grep .config
ls -la ~/.config | grep Code
ls -la ~/.config/Code

@Tyriar Tyriar added the info-needed Issue requires more information from poster label Apr 22, 2016
@ctaggart
Copy link
Author

ctaggart commented Apr 22, 2016

@Tyriar here is the output:

root@937050988adf:~# whoami
root
root@937050988adf:~# ls -la ~ | grep .config
drwx------  3 root root  4096 Apr 22 22:37 .config
root@937050988adf:~# ls -la ~/.config | grep Code
drwx------  3 root root 4096 Apr 22 22:51 Code
root@937050988adf:~# ls -la ~/.config/Code
total 16
drwx------ 3 root root 4096 Apr 22 22:51 .
drwx------ 3 root root 4096 Apr 22 22:37 ..
-rw-r--r-- 1 root root    2 Apr 22 22:58 DevTools Extensions
drwxr-xr-x 2 root root 4096 Apr 22 22:37 User

@Tyriar
Copy link
Member

Tyriar commented Apr 23, 2016

Weird, I would expect it to work provided the user has rw access to ~/.config. It might be an issue with Electron. The only things I can recommend are to try with a non-root user or installing via a package (though the latter probably won't make a difference).

@ctaggart
Copy link
Author

It appears to be an issue when running as root. The GUI came up when I ran as a user.

@ctaggart ctaggart changed the title no such file ~/.config/Code/storage.json on clean install of VSCode-linux-x64-stable.zip VSCode-linux-x64-stable.zip doesn't run as root Apr 24, 2016
@ctaggart
Copy link
Author

ctaggart commented May 7, 2016

@Tyriar In the April Iteration Plan I noticed:

Linux: Support running vscode with sudo permissions #3068 @Tyriar
Test #5062

I was hoping that this would allow me to launch VSCode as root. I downloaded the insiders build and tried launching it, but it doesn't launch and I don't get any output:

root@1f20642fd434:~# code-insiders --user-data-dir=/root/profile --version
1.1.0-insider
root@1f20642fd434:~# code-insiders --user-data-dir=/root/profile .        
root@1f20642fd434:~# pwd
/root

I noticed that a User subdirectory is created:

root@1f20642fd434:~# ls -al ./profile/User/
total 85
drwxr-xr-x 2 root root  68 May  7 19:48 .
drwxr-xr-x 3 root root 102 May  7 19:48 ..

Should it be possible to launch VSCode as root?

@ghost
Copy link

ghost commented May 20, 2016

I am experiencing a similar issue, just the opposite...I can run:

  • su root -> /opt/vsc/code
  • sudo /opt/svc/code
  • sudo -u non-root /opt/svc/code

but I cannot simply run from any user,

TypeError: Bad argument
    at TypeError (native)
    at ChildProcess.spawn (internal/child_process.js:278:26)
    at Object.exports.spawn (child_process.js:379:9)
    at /opt/visual-studio-code/resources/app/out/vs/workbench/electron-main/main.js:6:4539
    at new __dirname.undefined.t.Class.derive._oncancel (/opt/visual-studio-code/resources/app/out/vs/workbench/electron-main/main.js:5:9667)
    at Object.o [as getUnixUserEnvironment] (/opt/visual-studio-code/resources/app/out/vs/workbench/electron-main/main.js:6:4502)
    at I (/opt/visual-studio-code/resources/app/out/vs/workbench/electron-main/main.js:10:15570)
    at Object.<anonymous> (/opt/visual-studio-code/resources/app/out/vs/workbench/electron-main/main.js:10:16109)
    at e._invokeFactory (/opt/visual-studio-code/resources/app/out/vs/loader.js:4:13697)
    at e._complete (/opt/visual-studio-code/resources/app/out/vs/loader.js:4:14014)

...but as I said, If I use sudo and specify a non-root user it works.

@Tyriar Tyriar added help wanted Issues identified as good community contribution opportunities and removed info-needed Issue requires more information from poster labels May 20, 2016
@Tyriar
Copy link
Member

Tyriar commented May 20, 2016

I'm curious on what you guys think the best way to handle this is. I spend most of my time in Ubuntu so running as root is not usually a thing I'm allowed to do (su is locked down on Ubuntu). The recent change was specifically targeting sudo only as previously it hung when launched.

Here's the current situation:

It's a very bare-bones support situation at the moment, plus it focuses around running as sudo instead of root, which I don't think id -u differentiates between. So I believe the fixes I did may have made the situation worse when running as the root user instead of sudo on a non-root user.

Any input from the community would be greatly appreciated 😃

@ctaggart
Copy link
Author

I created this issue originally when making some docker images with VSCode on it. My solution was simply to create a vscode user that has sudo access. I'm happy with that solution, so I'm going to close this issue.

https://github.com/ctaggart/dotnet-vscode/blob/master/root/install-user.sh

@Tyriar
Copy link
Member

Tyriar commented May 23, 2016

Going to reopen, I'd eventually like to get it working as expected for root user, sudo and regular users.

@Tyriar Tyriar reopened this May 23, 2016
@Tyriar Tyriar added this to the Backlog milestone Apr 20, 2017
@Tyriar
Copy link
Member

Tyriar commented Apr 20, 2017

Closing since there are no plans to fix this any time soon and there is a workaround in #5679 (comment)

@Tyriar Tyriar closed this as completed Apr 20, 2017
@Tyriar Tyriar removed bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels Apr 20, 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
install-update VS Code installation and upgrade system issues linux Issues with VS Code on Linux
Projects
None yet
Development

No branches or pull requests

2 participants