Gal Grünfeld
Gal Grünfeld

Reputation: 840

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:

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?

Upvotes: 8

Views: 31130

Answers (4)

Matthew
Matthew

Reputation: 678

There is a simpler solution to this. Just specify the full path to the special directory you want to use for your debug chrome instance. In my case I set the user data directory to a folder next to the default user data directory, called "Debug". The following works for me specified as a script in my package.json:

"start-remote-debugging-browser": "C:\\PROGRA~2\\Google\\Chrome\\Application\\chrome.exe -incognito --app=http://localhost:4200/ --remote-debugging-port=9222 --user-data-dir=C:\\Users\\mmcin\\AppData\\Local\\Google\\Chrome\\User Data\\Debug"

Upvotes: 0

Anon
Anon

Reputation: 11

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

Upvotes: 1

Wardrox
Wardrox

Reputation: 71

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]);

Upvotes: 3

Adam Tuliper
Adam Tuliper

Reputation: 30152

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

Upvotes: 2

Related Questions