visual-studio-code

vs code is not creating the file in


I am trying to create file in vs code and this file is note creating in my current dir and it give the error like this

Permission denied writing to file (file:///home/tentron/hello-world/src/app/courses.component.ts)

I am using linux mint

when I try to open code as root user (sudo code "folder_name" <-|) it gave me warning like this

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 can't understand this ' --user-data-dir argument ' and how to use it


Solution

  • As vscode, I don't recommend you to launch code as super user, but here is how:

    sudo code --user-data-dir=/enter/path/here/
    

    bear in mind that that the given dir will populate with a lot of vscode files and folders.

    However, I would first check if you have writing permissions on the file you want to write/edit. In linux you can try sudo chmod 766 file_name that should give any user write permission.