blob: ef6c13417f145dab96526a1d2ae9ae2f086ae6b7 [file] [log] [blame] [view]
Steve Kobes22fb19c2017-07-05 21:49:081# User Data Directory
2
3[TOC]
4
5## Introduction
6
7The user data directory contains profile data such as history, bookmarks, and
8cookies, as well as other per-installation local state.
9
10Each [profile](https://support.google.com/chrome/answer/2364824) is a
11subdirectory (often `Default`) within the user data directory.
12
13## Current Location
14
15To determine the user data directory for a running Chrome instance:
16
171. Navigate to `chrome://version`
182. Look for the `Profile Path` field. This gives the path to the profile
19 directory.
203. The user data directory is the parent of the profile directory.
21
22Example (Windows):
23
24* [Profile Path] `C:\Users\Alice\AppData\Local\Google\Chrome\User Data\Default`
25* [User Data Dir] `C:\Users\Alice\AppData\Local\Google\Chrome\User Data`
26
27## Default Location
28
29The default location of the user data directory is computed by
30[`chrome::GetDefaultUserDataDirectory`](https://cs.chromium.org/chromium/src/chrome/common/chrome_paths_internal.h?q=GetDefaultUserDataDirectory).
31
32Generally it varies by
33
34* OS platform,
35* branding ([Chrome vs. Chromium](chromium_browser_vs_google_chrome.md), based
36 on `is_chrome_branded` in [GN
37 args](https://www.chromium.org/developers/gn-build-configuration)), and
38* [release channel](https://www.chromium.org/getting-involved/dev-channel)
39 (stable / beta / dev / canary).
40
41### Windows
42
43The default location is in the local app data folder:
44
45* [Chrome] `%LOCALAPPDATA%\Google\Chrome\User Data`
Raymond Toy4e6608072021-04-15 21:38:2646* [Chrome Beta] `%LOCALAPPDATA%\Google\Chrome Beta\User Data`
Steve Kobes22fb19c2017-07-05 21:49:0847* [Chrome Canary] `%LOCALAPPDATA%\Google\Chrome SxS\User Data`
48* [Chromium] `%LOCALAPPDATA%\Chromium\User Data`
49
50(The canary channel suffix is determined using
51[`InstallConstants::install_suffix`](https://cs.chromium.org/chromium/src/chrome/install_static/install_constants.h?q=install_suffix).)
52
53### Mac OS X
54
55The default location is in the `Application Support` folder:
56
57* [Chrome] `~/Library/Application Support/Google/Chrome`
Raymond Toy4e6608072021-04-15 21:38:2658* [Chrome Beta] `~/Library/Application Support/Google/Chrome Beta`
Steve Kobes22fb19c2017-07-05 21:49:0859* [Chrome Canary] `~/Library/Application Support/Google/Chrome Canary`
60* [Chromium] `~/Library/Application Support/Chromium`
61
62(The canary channel suffix is determined using the `CrProductDirName` key in the
63browser app's `Info.plist`.)
64
65### Linux
66
67The default location is in `~/.config`:
68
69* [Chrome Stable] `~/.config/google-chrome`
70* [Chrome Beta] `~/.config/google-chrome-beta`
71* [Chrome Dev] `~/.config/google-chrome-unstable`
72* [Chromium] `~/.config/chromium`
73
74(The beta and dev channel suffixes are determined from `$CHROME_VERSION_EXTRA`,
75which is passed by the [launch wrapper script](https://cs.chromium.org/chromium/src/chrome/installer/linux/common/wrapper?q=CHROME_VERSION_EXTRA).)
76
77The `~/.config` portion of the default location can be overridden by
78`$CHROME_CONFIG_HOME` (since M61) or by `$XDG_CONFIG_HOME`.
79
80Note that `$XDG_CONFIG_HOME` affects all applications conforming to the
81[XDG Base Directory Spec](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html),
82while `$CHROME_CONFIG_HOME` is specific to Chrome and Chromium.
83
84### Chrome OS
85
86The default location is: `/home/chronos`
87
88### Android
89
90The default location comes from
Steve Kobes49666412017-07-06 01:02:4991[Context.getDir](https://developer.android.com/reference/android/content/Context.html#getDir%28java.lang.String,%20int%29)
Steve Kobes22fb19c2017-07-05 21:49:0892and is specific to the app.
93
94Example: `/data/user/0/com.android.chrome/app_chrome`
95
96### iOS
97
98The default location is inside the application support directory in the app
99sandbox.
100
101* [Chrome] `Library/Application Support/Google/Chrome`
102* [Chromium] `Library/Application Support/Chromium`
103
104## Overriding the User Data Directory
105
106### Command Line
107
Zhaoyang Lif632baa2021-08-06 16:33:01108On most platforms, the user data directory can be overridden by passing the
Steve Kobes22fb19c2017-07-05 21:49:08109`--user-data-dir` command-line flag to the Chrome binary.
110
Zhaoyang Lif632baa2021-08-06 16:33:01111The override happens in `chrome/app/chrome_main_delegate.cc`. Platforms not
112building with the file may not have implemented the override. Overriding the
113user data directory via the command line is not supported on iOS.
114
Steve Kobes22fb19c2017-07-05 21:49:08115Example:
116
117* [Windows] `chrome.exe --user-data-dir=c:\foo`
118* [Linux] `google-chrome --user-data-dir=/path/to/foo`
119
120### Environment (Linux)
121
122On Linux, the user data directory can also be overridden with the
123`$CHROME_USER_DATA_DIR` environment variable.
124
125The `--user-data-dir` flag takes precedence if both are present.
126
127### Chrome Remote Desktop sessions (Linux)
128
129A single Chrome instance cannot show windows on multiple X displays, and two
130running Chrome instances cannot share the same user data directory.
131Therefore, it's desirable for Chrome to have a separate user data directory
132when running inside a [Chrome Remote
133Desktop](https://support.google.com/chrome/answer/1649523) (CRD) virtual session
134on a Linux host.
135
136By default, CRD achieves this by setting `$CHROME_USER_DATA_DIR` in the session.
137Unfortunately this means that inside the session we don't get separate defaults
138for different channels (Stable, Beta, Dev) or for Chrome vs. Chromium. This can
139lead to profile version errors ("Your profile can not be used because it is from
140a newer version of Google Chrome").
141
142Since M61, this can be solved by setting `$CHROME_CONFIG_HOME` instead of
143`$CHROME_USER_DATA_DIR`. Specifically, put the following in
144`~/.chrome-remote-desktop-session`:
145
146```
147export CHROME_CONFIG_HOME="$HOME/.config/chrome-remote-desktop/chrome-config"
148unset CHROME_USER_DATA_DIR
149. /etc/chrome-remote-desktop-session
150```
151
152Then restart the host by running: `/etc/init.d/chrome-remote-desktop restart`
153
154### Writing an AppleScript wrapper (Mac OS X)
155
156On Mac OS X, you can create an application that runs Chrome with a custom
157`--user-data-dir`:
158
1591. Open Applications > Utilities > Script Editor.
160
1612. Enter:
162
163```
164set chrome to "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\""
165set userdatadir to "\"$HOME/Library/Application Support/Google/Chrome Alt\""
166do shell script chrome & " --user-data-dir=" & userdatadir & " > /dev/null 2>&1 &"
167```
168
1693. Modify as needed for your installation path, Chrome versus Chromium, and
170 desired user data directory.
171
1724. Save the script in your Applications directory with the file format
173 "Application".
174
1755. Close the Script Editor, find your newly created application, and run it.
176 This opens a Chrome instance pointing to your new profile.
177
178If you want, you can give this application the same icon as Chrome:
179
1801. Select the Google Chrome application and choose File > Get Info.
1812. Select the icon at the top left of the info dialog. You will see a blue
182 highlight around the icon.
1833. Press ⌘C to copy the icon.
1844. Open the info dialog for the new application and select the icon in the
185 top left.
1865. Press ⌘V to paste the copied icon.
187
188## User Cache Directory
189
190On Windows and ChromeOS, the user cache dir is the same as the profile dir.
191(The profile dir is inside the user data dir.)
192
193On Mac OS X and iOS, the user cache dir is derived from the profile dir as
194follows:
195
1961. If `Library/Application Support` is an ancestor of the profile dir, the user
197 cache dir is `Library/Caches` plus the relative path from `Application
198 Support` to the profile dir.
1992. Otherwise, the user cache dir is the same as the profile dir.
200
201Example (Mac OS X):
202
203* [user data dir] `~/Library/Application Support/Google/Chrome`
204* [profile dir] `~/Library/Application Support/Google/Chrome/Default`
205* [user cache dir] `~/Library/Caches/Google/Chrome/Default`
206
207On Linux, the user cache dir is derived from the profile dir as follows:
208
2091. Determine the system config dir. This is `~/.config`, unless overridden by
210 `$XDG_CONFIG_HOME`. (This step ignores `$CHROME_CONFIG_HOME`.)
2112. Determine the system cache dir. This is `~/.cache`, unless overridden by
212 `$XDG_CACHE_HOME`.
2133. If the system config dir is an ancestor of the profile dir, the user cache
214 dir is the system cache dir plus the relative path from the system config
215 dir to the profile dir.
2164. Otherwise, the user cache dir is the same as the profile dir.
217
218Example (Linux):
219
220* [user data dir] `~/.config/google-chrome`
221* [profile dir] `~/.config/google-chrome/Default`
222* [user cache dir] `~/.cache/google-chrome/Default`
223
224On Android, the user cache directory comes from
Steve Kobese26f53bd2017-07-06 00:15:02225[Context.getCacheDir](https://developer.android.com/reference/android/content/Context.html#getCacheDir%28%29).