Search code examples
javascriptubuntuvisual-studio-codesudo

Can't open VSCode with other user


Well basically i created another user, and i'm tring to open a node project, but i can't use "code ." (i think it's because vscode is installed in the other user, but idk) without having the following error:

~/amq-javascript-2.5.0/node_modules/rhea$ code .

2020/02/12 10:02:20.859002 cmd_run.go:884: WARNING: cannot create user data directory: cannot create "/home/amq-broker/snap/code/24": mkdir /home/amq-broker/snap: permission denied cannot create user data directory: /home/amq-broker/snap/code/24: Permission denied

I already tryed with sudo, and got this:

~/amq-javascript-2.5.0/node_modules/rhea$ sudo code .

You are trying to start vscode as a super user which is not recommended. If you really want to, you must specify an alternate user data directory using the --user-data-dir argument.

I'm kinda lost here...


Solution

  • I had the same issue. I was able to finally get it to work by running ...

    sudo code . --user-data-dir='.'
    

    OR

    sudo code --user-data-dir /home/fregie/.config/Code/ doesn't work because it needs to be a new user data directory, one whose permissions are not as restrictive as ~/.config.

    This should work for example:

    sudo code --user-data-dir /home/fregie/.code-root-user-data
    

    Note that once we reshuffle the configuration directories this will no longer be necessary to explicitly indicate the root user data dir