0

In the new update, vscode doesn't open as root in debian. Even after specifying an alternative directory using --user-data-dir

Has anyone ever faced this issue in the new update of vscode or is there any way to fix this? The terminal doesn't output any errors after executing the command (it just doesn't open as root). I couldn't find any solution online either because most of the vscode and root account related problems are associated with the person failing to specify path using --user-data-dir and in my case it doesn't open at all.

Operating system: Debian 10

Vscode version: 1.58.2-1626302803

[NOTE: I didn't face this issue until I updated to version 1.58.2-1626302803. The old versions of vscode was working fine in the root account.]

3
  • 7
    Why would anyone ever want to run an IDE as the root user? What's the point? Remember: IDEs are dangerous, they can run all sorts of compilations and execute compiled programs and scripts. Running them as root is like asking them to damage your machine. Next time you have a bug and run rm -r $path/* with $path undefined, you will wipe your hard drive. Do not run things as root unless absolutely necessary. There are always better ways.. Commented Jul 24, 2021 at 13:41
  • While I share the sentiment that this is dangerous (because you're essentially running a web browser as root), I suspect the OP uses VS Code as their preferred editor and either doesn't want to use a terminal-based editor under sudo or isn't familiar with one. Commented Jul 25, 2021 at 0:28
  • 3
    @bk2204 IDE is a different type of software than a text editor. There are numerous GUI text editors for all kinds of DEs under GNU/Linux, but using GUI programs as root is generally discouraged. If the OP is unfamiliar with vi/vim or emacs, he can use more "friendly" text editors like nano or pico instead. System administration is not a trivial task. Commented Apr 10, 2022 at 13:37

3 Answers 3

5

The code script eventually executes:

/usr/share/code/bin/../code /usr/share/code/bin/../resources/app/out/cli.js --user-data-dir /tmp/ff

which comes back with:

[6113:0724/111813.659159:FATAL:electron_main_delegate.cc(263)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.
Trace/breakpoint trap (core dumped)

Adding --no-sandbox does bring up the window.

The moral of this story, they really do not want you to run as root.

3

This should do it for you. The --disable-gpu-sandbox seems to be the option most threads I've seen online on the topic are missing.

...and listen.... I can appreciate everyone saying "you don't want to run as root". To which I say, yea obviously. But we're all professionals here. Sometimes there are use cases. Rather than lecturing the OP on how he/she sucks at life when we know nothing about the use case, how about we add value and answer the question instead?

Adjust your user directory below as required...

sudo code --user-data-dir=/home/kali/.config/Code/ --no-sandbox --disable-gpu-sandbox
1
  • I upvoted this alone for the follow-on commentary, but an additional +1 because this is the only solution out there which fixes this for linux mint to date. relevant sudo use case: trying to install the amazing Synthwave x Fluoromachine & epic animation plugin Commented Apr 19, 2023 at 5:23
1

You can try code --user-data-dir /opt/your_path/.vscode (or .vscode-root) --no-sandbox.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.