Failed to Create Data Directory - Google Chrome Cannot Read and Write Its Data Directory - Cordova
Solution 1
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
Solution 2
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
Solution 3
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]);
Gal Grünfeld
Web developer and data scientist, power user of life, with interest in mathematics, science, technology, history and music. I good UI and UX, nature, playing guitar, singing, listening to music, traveling, gaming, and, sure, why not, long walks on the beach.
Updated on January 18, 2020Comments
-
Gal Grünfeld over 4 years
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?
-
Reuven Karasik over 8 yearsMight be something to do with permissions. Can you make sure the folder exists in the right location, is writable, and the user has permissions? (I don't know much about the subject but that's my best guess)
-
Gal Grünfeld over 8 yearsWhich folder? The one in which Google Chrome is installed, its userdata, or my Cordova project folder?
-
Reuven Karasik over 8 yearsI meant the folder which is mentioned in the error, 'C:/Chromedevsession'. I have no idea whether it should be there or not, but since Chrome gives you an error that says it cannot read it, just make sure that it can and the error would be gone. Just common sense.
-
Gal Grünfeld over 8 yearsThere's no such folder or file.
-
vicentedealencar over 8 yearsI am having the same issue :(
-
Matthew over 4 yearsThis should not be necessary. Posting an alternative solution below.