blob: 8cbf64526085856b9a36852857a2ad30b20adc4c [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`
46* [Chrome Canary] `%LOCALAPPDATA%\Google\Chrome SxS\User Data`
47* [Chromium] `%LOCALAPPDATA%\Chromium\User Data`
48
49(The canary channel suffix is determined using
50[`InstallConstants::install_suffix`](https://cs.chromium.org/chromium/src/chrome/install_static/install_constants.h?q=install_suffix).)
51
52### Mac OS X
53
54The default location is in the `Application Support` folder:
55
56* [Chrome] `~/Library/Application Support/Google/Chrome`
57* [Chrome Canary] `~/Library/Application Support/Google/Chrome Canary`
58* [Chromium] `~/Library/Application Support/Chromium`
59
60(The canary channel suffix is determined using the `CrProductDirName` key in the
61browser app's `Info.plist`.)
62
63### Linux
64
65The default location is in `~/.config`:
66
67* [Chrome Stable] `~/.config/google-chrome`
68* [Chrome Beta] `~/.config/google-chrome-beta`
69* [Chrome Dev] `~/.config/google-chrome-unstable`
70* [Chromium] `~/.config/chromium`
71
72(The beta and dev channel suffixes are determined from `$CHROME_VERSION_EXTRA`,
73which is passed by the [launch wrapper script](https://cs.chromium.org/chromium/src/chrome/installer/linux/common/wrapper?q=CHROME_VERSION_EXTRA).)
74
75The `~/.config` portion of the default location can be overridden by
76`$CHROME_CONFIG_HOME` (since M61) or by `$XDG_CONFIG_HOME`.
77
78Note that `$XDG_CONFIG_HOME` affects all applications conforming to the
79[XDG Base Directory Spec](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html),
80while `$CHROME_CONFIG_HOME` is specific to Chrome and Chromium.
81
82### Chrome OS
83
84The default location is: `/home/chronos`
85
86### Android
87
88The default location comes from
Steve Kobese26f53bd2017-07-06 00:15:0289[Context.getDir](https://developer.android.com/reference/android/content/Context.html#getDir%28java.lang.String, int%29)
Steve Kobes22fb19c2017-07-05 21:49:0890and is specific to the app.
91
92Example: `/data/user/0/com.android.chrome/app_chrome`
93
94### iOS
95
96The default location is inside the application support directory in the app
97sandbox.
98
99* [Chrome] `Library/Application Support/Google/Chrome`
100* [Chromium] `Library/Application Support/Chromium`
101
102## Overriding the User Data Directory
103
104### Command Line
105
106On all platforms, the user data directory can be overridden by passing the
107`--user-data-dir` command-line flag to the Chrome binary.
108
109Example:
110
111* [Windows] `chrome.exe --user-data-dir=c:\foo`
112* [Linux] `google-chrome --user-data-dir=/path/to/foo`
113
114### Environment (Linux)
115
116On Linux, the user data directory can also be overridden with the
117`$CHROME_USER_DATA_DIR` environment variable.
118
119The `--user-data-dir` flag takes precedence if both are present.
120
121### Chrome Remote Desktop sessions (Linux)
122
123A single Chrome instance cannot show windows on multiple X displays, and two
124running Chrome instances cannot share the same user data directory.
125Therefore, it's desirable for Chrome to have a separate user data directory
126when running inside a [Chrome Remote
127Desktop](https://support.google.com/chrome/answer/1649523) (CRD) virtual session
128on a Linux host.
129
130By default, CRD achieves this by setting `$CHROME_USER_DATA_DIR` in the session.
131Unfortunately this means that inside the session we don't get separate defaults
132for different channels (Stable, Beta, Dev) or for Chrome vs. Chromium. This can
133lead to profile version errors ("Your profile can not be used because it is from
134a newer version of Google Chrome").
135
136Since M61, this can be solved by setting `$CHROME_CONFIG_HOME` instead of
137`$CHROME_USER_DATA_DIR`. Specifically, put the following in
138`~/.chrome-remote-desktop-session`:
139
140```
141export CHROME_CONFIG_HOME="$HOME/.config/chrome-remote-desktop/chrome-config"
142unset CHROME_USER_DATA_DIR
143. /etc/chrome-remote-desktop-session
144```
145
146Then restart the host by running: `/etc/init.d/chrome-remote-desktop restart`
147
148### Writing an AppleScript wrapper (Mac OS X)
149
150On Mac OS X, you can create an application that runs Chrome with a custom
151`--user-data-dir`:
152
1531. Open Applications > Utilities > Script Editor.
154
1552. Enter:
156
157```
158set chrome to "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\""
159set userdatadir to "\"$HOME/Library/Application Support/Google/Chrome Alt\""
160do shell script chrome & " --user-data-dir=" & userdatadir & " > /dev/null 2>&1 &"
161```
162
1633. Modify as needed for your installation path, Chrome versus Chromium, and
164 desired user data directory.
165
1664. Save the script in your Applications directory with the file format
167 "Application".
168
1695. Close the Script Editor, find your newly created application, and run it.
170 This opens a Chrome instance pointing to your new profile.
171
172If you want, you can give this application the same icon as Chrome:
173
1741. Select the Google Chrome application and choose File > Get Info.
1752. Select the icon at the top left of the info dialog. You will see a blue
176 highlight around the icon.
1773. Press ⌘C to copy the icon.
1784. Open the info dialog for the new application and select the icon in the
179 top left.
1805. Press ⌘V to paste the copied icon.
181
182## User Cache Directory
183
184On Windows and ChromeOS, the user cache dir is the same as the profile dir.
185(The profile dir is inside the user data dir.)
186
187On Mac OS X and iOS, the user cache dir is derived from the profile dir as
188follows:
189
1901. If `Library/Application Support` is an ancestor of the profile dir, the user
191 cache dir is `Library/Caches` plus the relative path from `Application
192 Support` to the profile dir.
1932. Otherwise, the user cache dir is the same as the profile dir.
194
195Example (Mac OS X):
196
197* [user data dir] `~/Library/Application Support/Google/Chrome`
198* [profile dir] `~/Library/Application Support/Google/Chrome/Default`
199* [user cache dir] `~/Library/Caches/Google/Chrome/Default`
200
201On Linux, the user cache dir is derived from the profile dir as follows:
202
2031. Determine the system config dir. This is `~/.config`, unless overridden by
204 `$XDG_CONFIG_HOME`. (This step ignores `$CHROME_CONFIG_HOME`.)
2052. Determine the system cache dir. This is `~/.cache`, unless overridden by
206 `$XDG_CACHE_HOME`.
2073. If the system config dir is an ancestor of the profile dir, the user cache
208 dir is the system cache dir plus the relative path from the system config
209 dir to the profile dir.
2104. Otherwise, the user cache dir is the same as the profile dir.
211
212Example (Linux):
213
214* [user data dir] `~/.config/google-chrome`
215* [profile dir] `~/.config/google-chrome/Default`
216* [user cache dir] `~/.cache/google-chrome/Default`
217
218On Android, the user cache directory comes from
Steve Kobese26f53bd2017-07-06 00:15:02219[Context.getCacheDir](https://developer.android.com/reference/android/content/Context.html#getCacheDir%28%29).