Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to Create Data Directory - Google Chrome Cannot Read and Write Its Data Directory - Cordova

I've been working on a Cordova app, and I've suddenly had troubles with Chrome. I've wanted to start debugging, so I added support for a browser platform, and I use Chrome.

After running the app on Chrome, which worked before, I encountered this problem:

Failed To Create Data Directory

Google Chrome cannot read and write its data directory:

C:/Chromedevsession"

screenshot here: http://prntscr.com/876kax

Things I tried:

  • Deleting Chrome -> Reinstalling Chrome - found this online
  • Deleting Windows registry key HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome - there's no Chrome folder or key inside the Google folder, only an Update folder
  • While uninstalled, using a different browser as my default browser - the command that runs the app (cordova run) didn't open another browser (I tried Firefox).

It already worked before, and I don't know why it suddenly happened. I tried upgrading to Windows 10 a few times and it failed, so could there be a problem in the registry?

like image 651
Gal Grünfeld Avatar asked Aug 21 '15 11:08

Gal Grünfeld


3 Answers

This is because the script that launches chrome, uses a folder location that typically can't be created with your permissions. That folder is used for history, bookmarks, cookies, etc (ie user data). This is beneficial for testing out features in Chrome (plugins, etc) and not affecting your normal instance. I don't consider it much of a concern here, more of a nuisance message. If you don't like it you could always just manually create that folder on your system as well.

You can see this here what causes the issue

switch (process.platform) {
  case 'darwin':
    spawn('open', ['-n', '-a', 'Google\ Chrome', '--args', '--disable-web-security', '--user-data-dir=/tmp/temp_chrome_user_data_dir_for_cordova_browser', project]);
    break;
  case 'win32':
    //TODO: Use regex to fix location of chrome.exe
    //TODO: Get --user-data-dir to work for windows
    spawn('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', ['--user-data-dir="C:/Chromedevsession"', '--disable-web-security', project]);
    break;
}

Since it can't use that folder, I believe it just reverts to the defaults which on Windows 10 would be

C:\Users\%USERNAME%\AppData\Local\Google\Chrome\User Data\Default
like image 166
Adam Tuliper Avatar answered Oct 12 '22 10:10

Adam Tuliper


I solved this issue by editing the run file (platforms/browser/cordova/run) and removing the speech marks from around C:/Chromedevsession on line 33.

The line now reads:

spawn('C:/Program Files (x86)/Google/Chrome/Application/chrome.exe', ['--user-data-dir=C:/Chromedevsession', '--disable-web-security', project]);
like image 24
Wardrox Avatar answered Oct 12 '22 10:10

Wardrox


Remove Space in Path in Registry Policy

HKEY_CURRENT_USER\Software\Policies\Google\Chrome\UserDataDir

or

HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Google\Chrome\UserDataDir

Example:

${roaming_app_data}\Google\Chrome\User_Data

instead of

${roaming_app_data}\Google\Chrome\User Data

like image 1
Anon Avatar answered Oct 12 '22 10:10

Anon