Home > Software engineering >  How to undo after running sudo code . --user-data-dir='.'?
How to undo after running sudo code . --user-data-dir='.'?

Time:12-18

I was doing the VSCode configuration, but accidentally I saw this command line which I am not sure what it is doing.

However, after running, it always creates the cache data whenever I start my VSCode.

Note: Whenever I typed this command in any directory, it'll automatically shown those folder and file in that directory.

enter image description here

CodePudding user response:

I used to face this problem before. I did a bit of research what is --user-data-dir mean.

code --help

--user-data-dir Specifies the directory that user data is kept in. Can be used to open multiple distinct instances of Code.

With the command above it means you try to run vscode instance with root permission. I couldn't find a way to close that instances. so I just simply restart my computer and remove the all folders you have mentioned in the image. Then the those cache folder never come back again.

I hope this can help. Thank you.

CodePudding user response:

By setting --user-data-dir you're telling VS Code where it should keep your user / session data, which is why it's creating all of those new directories. This is necessary because when you run code as sudo, it doesn't know where your user data directory is, since you're running as a different user. Like this answer says, you probably shouldn't be running code with sudo: VSCode - what exactly --user-data-dir is specifiying. See that answer for suggestions on alternatives.

As for deleting the data it made, just a simple sudo rm -rf <dir> should do the trick (be careful of course).

  • Related