Vscode: “Unable to write program user data” when invoking VS Code as git editor

Created on 14 Feb 2019  Â·  24Comments  Â·  Source: microsoft/vscode


  • VSCode Version: 1.31.0
  • OS Version: Ubuntu 18.04.1 LTS

Steps to Reproduce:

  1. Enter a git-tracked directory
  2. Run GIT_EDITOR='code --wait' git commit --allow-empty
  3. Observe an error dialog appears:

    Unable to write program user data.

    Please make sure the directory /home/mat/.config/Code is writeable

Just to make sure, I did recursively make that directory world-writable, but it didn’t help.

I tried it with today’s code-insiders build and the issue persists.


Does this issue occur when all extensions are disabled?: Yes

needs more info

Most helpful comment

SOLVED by deleting the Code directory from /home/MyUserDirectory/.config and then re-starting VScode from the menu.

To be clear:
$ code

::Pop up with Unable to write program user data::

$ cd /home/YourUserDirectory/.config
$ sudo rm -rf Code
[enter your password as needed]
$
[no news is good news...so you should only get a prompt back - meaning, the directory and all its contents got deleted]
$ code
[or launch from the menu]
took an extra moment... and then VSCode came right up!

Before this I had tried installing with Anaconda-Navigator, which is where the 'cannot write' error started... uninstalled... re-installed Anaconda.. no improvement. Then manually uninstalled and re-installed. Still no help... Searched on the error message and found this article... scrolled all the way down... only to find @AHermann94 explaining that manually deleting the folders after uninstalling worked... so I thought I would see what would happen if I just deleted the offending folder... And it WORKED! I figured the program might re-create the folder if it couldn't find it... looks like it did.

Happy coding!

All 24 comments

What happens when you run code?

@joaomoreno it opens VS Code as expected.

I use CentOS 7. get an error just by running code.
After a recent update VSCode have this issue.

@outoftime How about code --wait?

@joaomoreno invoking code --wait from the terminal opens VS Code as expected

Can you show me a screenshot of that error dialog?

I'm getting the same error:
screenshot from 2019-02-20 15-07-27

Update: I no longer have this problem on VS Code 1.31.1:

$ code --version
1.31.1
1b8e8302e405050205e69b59abb3559592bb9e60
x64

I am encountering a different bug, which is that the commit editor always opens in a new window, even when the commit is initiated from the integrated terminal, and even when --reuse-window is supplied as an option. I will open a separate issue for that.

i got the same error as well.. on version 1.31.1.

if I run code it pops up the same message, but a manual open works. can confirm on the latest version. also code --wait pops up the same message too.

@bpasero Have you seen this?

This dialog is from us when we get an error of type EACCESS or EPERM on startup:

https://github.com/Microsoft/vscode/blob/ce073b0076ac2f69faf2c609af72f9b81506c791/src/vs/code/electron-main/main.ts#L215L222

@weichea @Technical27 Can you check permissions on that folder?

@joaomoreno I did note in the original bug report that I had tried recursively making the folder world-writable and it did not help.

Now code and code --wait works fine now after closing my terminal after using
chmod -R +rw ~/.config/Code
This will give everything in the folder write and read permissions
EDIT: I know this won't help OP but I am leaving it here to help anyone else

@bpasero The error message has a bug, the path its referring to is just the config setting not the one path generating the error, any path could be causing it.

This means people in this thread could be having a number of different issues.

My issue is potentially just a dupe of #3884 but I'm not sure.

I disable write access to my home dir specifically because of things like this so seeing this error and suspecting home dir access was probably the issue, I enabled writes and once again could start code without the error. Only now with a ~/.vscode-oss/extensions path being created.

Deleting the .vscode-oss directory and adding this env var lets me start code without the error and without the needless home dir pollution.

export VSCODE_EXTENSIONS="${XDG_DATA_HOME:-~/.local/share}/code-oss/extensions"

@lsl good catch. I pushed a change so that the error dialog talks about both the user data path as well as the extensions path. Both need to be writable for VSCode to startup properly.

I'm getting the same error:
i have the same problem.
how did you solve it ? thanks

@lsl unfortunatelly, I do not understand your solution. Could you please explain it to me?
where exatly did you add the env var? where is this document at all?
I have Ubuntu 18.04.
To be honest, I can't even find the files from vscode, except for the one file named "code" in usr/bin/.
Could you please help me out?

Kind regards,
An Ubuntu noob.

Never mind. Solved the problem by deinstalling and manually deleting the directories home/.vscode and home/.config/Code. Then installing it again by downloading the .deb file from the official site and installing it using the command sudo install ./code_1.32.2-1552488294_amd64.deb

SOLVED by deleting the Code directory from /home/MyUserDirectory/.config and then re-starting VScode from the menu.

To be clear:
$ code

::Pop up with Unable to write program user data::

$ cd /home/YourUserDirectory/.config
$ sudo rm -rf Code
[enter your password as needed]
$
[no news is good news...so you should only get a prompt back - meaning, the directory and all its contents got deleted]
$ code
[or launch from the menu]
took an extra moment... and then VSCode came right up!

Before this I had tried installing with Anaconda-Navigator, which is where the 'cannot write' error started... uninstalled... re-installed Anaconda.. no improvement. Then manually uninstalled and re-installed. Still no help... Searched on the error message and found this article... scrolled all the way down... only to find @AHermann94 explaining that manually deleting the folders after uninstalling worked... so I thought I would see what would happen if I just deleted the offending folder... And it WORKED! I figured the program might re-create the folder if it couldn't find it... looks like it did.

Happy coding!

Curious. I also first installed it with anaconda (after installing anaconda, it asks you if you want to also install vscode). So probably an error in the way anaconda installs it.

@AHermann94 the error is caused by corrupted permissions/ownership in your config/data files.

You can either fix the permission/ownership issues or just delete everything and start fresh.

Check ownership / permissions: ls -al ~/.code ~/.vscode* ~/.config/Code*

Delete all config / extensions and start over:

rm -r ~/.code
rm -r ~/.vscode*
rm -r ~/.config/Code*

.code and .config/Code* are equivalent, .vscode is where extensions live. One or more of these may not exist, ignore the not found / no match errors. Use sudo if something can't be deleted.

For windows users you probably need to see #3884 for the APPDATA dirs.

I had this message pop up on my openSUSE Leap 15.0 installation until I granted group/world write permission to the /run/user directory so that VS Code could write "*.sock" files there.

Was this page helpful?
0 / 5 - 0 ratings