You are not logged in.

#1 2020-03-29 18:48:14

CupricSage
Member
Registered: 2020-03-29
Posts: 4

[SOLVED] Visual Studio Code runs only as root user

Hello everyone,

Forgive me if my question is stupid, but I spent a lot of time finding a solution to my problem and unfortunately I failed. I have installed visual-studio-code-bin(AUR) on my Arch and I have a problem to run code without sudo. If I just type:

code

then nothing happens. If I run the program with:

sudo code  --user-data-dir

it immediately starts. Is this a problem with permissions? Someone had such a problem and can advise me what I'm doing wrong?

Thank you in advance for all your answers.

Last edited by CupricSage (2020-04-01 18:27:19)

Offline

#2 2020-03-31 00:36:41

Spb1994
Member
Registered: 2020-03-31
Posts: 3

Re: [SOLVED] Visual Studio Code runs only as root user

What is the output of

which code | xargs ls -lhr

What are you specifying as the data directory (what comes after --user-data-dir) and what is in it?

Does VS Code run without the --user-data-dir option?

Did you use an AUR helper to install? If so, which one?

Last edited by Spb1994 (2020-03-31 00:38:06)

Offline

#3 2020-03-31 17:42:51

CupricSage
Member
Registered: 2020-03-29
Posts: 4

Re: [SOLVED] Visual Studio Code runs only as root user

This is the output:

lrwxrwxrwx 1 root root 32 Mar 29 18:46 /usr/bin/code -> /opt/visual-studio-code/bin/code

The problem is that the program starts only if I add --user-data-dir with some parameter, for example I use: VSCode/Code and it works. But there is any option to save this directory as default so that I don't have to give it each time?
I didn't use any AUR helper, just git for clone and makepkg to build package.

Offline

#4 2020-03-31 19:01:52

Spb1994
Member
Registered: 2020-03-31
Posts: 3

Re: [SOLVED] Visual Studio Code runs only as root user

This sounds like it could be a permissions issue. Can you check the permissions of /opt/visual-studio-code directory? For reference, here are my permissions for the /opt/visual-studio-code directory and the actual VS Code binary

drwxr-xr-x 6 root root 4096 Mar 30 20:11 visual-studio-code
-rwxr-xr-x 1 root root 1637 Mar 30 20:07 code

As for the data dir issue, see if directory ~/.config/Code is present. If so, verify your permissions against mine.

drwx------ 13 myusername myusername  4096 Mar 31 14:54 Code

Offline

#5 2020-03-31 20:49:36

CupricSage
Member
Registered: 2020-03-29
Posts: 4

Re: [SOLVED] Visual Studio Code runs only as root user

My permissions for the /opt/visual-studio-code and VS Code binary:

drwxr-xr-x 6 root root 4096 Mar 29 18:53 visual-studio-code
-rwxr-xr-x 1 root root 1653 Mar 30 20:08 code

I checked again to make sure the folder Code exists in the ~/.config/ directory, and it is there with a such permissions:

drwx------ 7 myuser usersgroup 4096 Mar 31 22:27 Code

It is interesting that the program starts if I give it this location, but each time I have to do it by entering

code --user-data-dir=~/.config/Code

It seems like it doesn't know the default folder directory.

Offline

#6 2020-04-01 01:00:16

Spb1994
Member
Registered: 2020-03-31
Posts: 3

Re: [SOLVED] Visual Studio Code runs only as root user

CupricSage wrote:

It is interesting that the program starts if I give it this location, but each time I have to do it by entering

code --user-data-dir=~/.config/Code

It seems like it doesn't know the default folder directory.

Are you able to run VS code without sudo if you specify ~/.config/Code? If so, then try renaming (not deleting) that directory and running vs code without specifying a data directory. I'm curious if there's something going on with the contents of the ~/.config/Code directory...

Offline

#7 2020-04-01 07:19:43

umbrelluck
Member
Registered: 2019-09-25
Posts: 12

Re: [SOLVED] Visual Studio Code runs only as root user

Try running

code --verbose

to see what is going on with VScode on startup
As mentioned here, it might be some permission issue.

Offline

#8 2020-04-01 18:25:59

CupricSage
Member
Registered: 2020-03-29
Posts: 4

Re: [SOLVED] Visual Studio Code runs only as root user

Spb1994 wrote:

Are you able to run VS code without sudo if you specify ~/.config/Code?

Yes, it was possible. Therefore, I already doubted that this is a problem with the permission of a file or folder, but after type the command

code --verbose

I saw that something is wrong with the folder ~/.config/Code/User. I changed the folder owner to my user and it worked! I can now start VSC with the "code" command.

Thank you Spb1994 and umbrelluck for help, problem solved smile

Offline

#9 2020-04-01 18:34:50

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] Visual Studio Code runs only as root user

CupricSage wrote:

I saw that something is wrong with the folder ~/.config/Code/User. I changed the folder owner to my user and it worked! I can now start VSC with the "code" command.

This folder will have only had incorrect permissions because you used sudo to launch the application, if you hadn't have done this your issue wouldn't have arised.

TLDR - Don't use sudo unless you know why you need to use it.


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB