blob: f4e2ad6b8b5409e5e91756cf7cd16b2f66d5892b [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`
Peter Kvitekb21d6202024-10-04 12:06:0448* [Chrome for Testing] `%LOCALAPPDATA%\Google\Chrome for Testing\User Data`
Steve Kobes22fb19c2017-07-05 21:49:0849* [Chromium] `%LOCALAPPDATA%\Chromium\User Data`
50
51(The canary channel suffix is determined using
52[`InstallConstants::install_suffix`](https://cs.chromium.org/chromium/src/chrome/install_static/install_constants.h?q=install_suffix).)
53
54### Mac OS X
55
56The default location is in the `Application Support` folder:
57
58* [Chrome] `~/Library/Application Support/Google/Chrome`
Raymond Toy4e6608072021-04-15 21:38:2659* [Chrome Beta] `~/Library/Application Support/Google/Chrome Beta`
Steve Kobes22fb19c2017-07-05 21:49:0860* [Chrome Canary] `~/Library/Application Support/Google/Chrome Canary`
Peter Kvitekb21d6202024-10-04 12:06:0461* [Chrome for Testing] `~/Library/Application Support/Google/Chrome for Testing`
Steve Kobes22fb19c2017-07-05 21:49:0862* [Chromium] `~/Library/Application Support/Chromium`
63
64(The canary channel suffix is determined using the `CrProductDirName` key in the
65browser app's `Info.plist`.)
66
67### Linux
68
69The default location is in `~/.config`:
70
71* [Chrome Stable] `~/.config/google-chrome`
72* [Chrome Beta] `~/.config/google-chrome-beta`
73* [Chrome Dev] `~/.config/google-chrome-unstable`
Peter Kvitekb21d6202024-10-04 12:06:0474* [Chrome for Testing] `~/.config/google-chrome-for-testing`
Steve Kobes22fb19c2017-07-05 21:49:0875* [Chromium] `~/.config/chromium`
76
77(The beta and dev channel suffixes are determined from `$CHROME_VERSION_EXTRA`,
78which is passed by the [launch wrapper script](https://cs.chromium.org/chromium/src/chrome/installer/linux/common/wrapper?q=CHROME_VERSION_EXTRA).)
79
80The `~/.config` portion of the default location can be overridden by
81`$CHROME_CONFIG_HOME` (since M61) or by `$XDG_CONFIG_HOME`.
82
83Note that `$XDG_CONFIG_HOME` affects all applications conforming to the
84[XDG Base Directory Spec](https://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html),
85while `$CHROME_CONFIG_HOME` is specific to Chrome and Chromium.
86
87### Chrome OS
88
89The default location is: `/home/chronos`
90
91### Android
92
93The default location comes from
Steve Kobes49666412017-07-06 01:02:4994[Context.getDir](https://developer.android.com/reference/android/content/Context.html#getDir%28java.lang.String,%20int%29)
Steve Kobes22fb19c2017-07-05 21:49:0895and is specific to the app.
96
97Example: `/data/user/0/com.android.chrome/app_chrome`
98
99### iOS
100
101The default location is inside the application support directory in the app
102sandbox.
103
104* [Chrome] `Library/Application Support/Google/Chrome`
105* [Chromium] `Library/Application Support/Chromium`
106
107## Overriding the User Data Directory
108
109### Command Line
110
Zhaoyang Lif632baa2021-08-06 16:33:01111On most platforms, the user data directory can be overridden by passing the
Steve Kobes22fb19c2017-07-05 21:49:08112`--user-data-dir` command-line flag to the Chrome binary.
113
Zhaoyang Lif632baa2021-08-06 16:33:01114The override happens in `chrome/app/chrome_main_delegate.cc`. Platforms not
115building with the file may not have implemented the override. Overriding the
116user data directory via the command line is not supported on iOS.
117
Steve Kobes22fb19c2017-07-05 21:49:08118Example:
119
120* [Windows] `chrome.exe --user-data-dir=c:\foo`
121* [Linux] `google-chrome --user-data-dir=/path/to/foo`
122
123### Environment (Linux)
124
125On Linux, the user data directory can also be overridden with the
126`$CHROME_USER_DATA_DIR` environment variable.
127
128The `--user-data-dir` flag takes precedence if both are present.
129
130### Chrome Remote Desktop sessions (Linux)
131
Yuwei Huang6c8d6ad2022-08-02 21:25:25132[Chrome Remote
133Desktop](https://support.google.com/chrome/answer/1649523) (CRD) used to set
134`$CHROME_USER_DATA_DIR` or `$CHROME_CONFIG_HOME` on the virtual session on a
135Linux host, since a single Chrome instance cannot show windows on multiple X
136displays, and two running Chrome instances cannot share the same user data
137directory. However, with the obsolescence of `dbus-x11`, most modern Linux
138distros have lost the ability to simultaneously run multiple graphical sessions
139for the same user without running into difficult-to-trace dbus cross talk
140issues, and Chrome can only be run on a single X display per user in reality.
141Therefore, CRD no longer sets these environment variables for new installations
142after CRD host M105.
Steve Kobes22fb19c2017-07-05 21:49:08143
Yuwei Huang6c8d6ad2022-08-02 21:25:25144The CRD host will continue to set these environment variables if either
145`chrome-config/` or `chrome-profile/` exists in
146`~/.config/chrome-remote-desktop/`. If you want to use the local Chrome profile
147in CRD sessions, quit Chrome and delete these folders from
148`~/.config/chrome-remote-desktop/`, then reboot the host device.
Steve Kobes22fb19c2017-07-05 21:49:08149
150### Writing an AppleScript wrapper (Mac OS X)
151
152On Mac OS X, you can create an application that runs Chrome with a custom
153`--user-data-dir`:
154
1551. Open Applications > Utilities > Script Editor.
156
1572. Enter:
158
159```
160set chrome to "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\""
161set userdatadir to "\"$HOME/Library/Application Support/Google/Chrome Alt\""
162do shell script chrome & " --user-data-dir=" & userdatadir & " > /dev/null 2>&1 &"
163```
164
1653. Modify as needed for your installation path, Chrome versus Chromium, and
166 desired user data directory.
167
1684. Save the script in your Applications directory with the file format
169 "Application".
170
1715. Close the Script Editor, find your newly created application, and run it.
172 This opens a Chrome instance pointing to your new profile.
173
174If you want, you can give this application the same icon as Chrome:
175
1761. Select the Google Chrome application and choose File > Get Info.
1772. Select the icon at the top left of the info dialog. You will see a blue
178 highlight around the icon.
1793. Press ⌘C to copy the icon.
1804. Open the info dialog for the new application and select the icon in the
181 top left.
1825. Press ⌘V to paste the copied icon.
183
184## User Cache Directory
185
186On Windows and ChromeOS, the user cache dir is the same as the profile dir.
187(The profile dir is inside the user data dir.)
188
189On Mac OS X and iOS, the user cache dir is derived from the profile dir as
190follows:
191
1921. If `Library/Application Support` is an ancestor of the profile dir, the user
193 cache dir is `Library/Caches` plus the relative path from `Application
194 Support` to the profile dir.
1952. Otherwise, the user cache dir is the same as the profile dir.
196
197Example (Mac OS X):
198
199* [user data dir] `~/Library/Application Support/Google/Chrome`
200* [profile dir] `~/Library/Application Support/Google/Chrome/Default`
201* [user cache dir] `~/Library/Caches/Google/Chrome/Default`
202
203On Linux, the user cache dir is derived from the profile dir as follows:
204
2051. Determine the system config dir. This is `~/.config`, unless overridden by
206 `$XDG_CONFIG_HOME`. (This step ignores `$CHROME_CONFIG_HOME`.)
2072. Determine the system cache dir. This is `~/.cache`, unless overridden by
208 `$XDG_CACHE_HOME`.
2093. If the system config dir is an ancestor of the profile dir, the user cache
210 dir is the system cache dir plus the relative path from the system config
211 dir to the profile dir.
2124. Otherwise, the user cache dir is the same as the profile dir.
213
214Example (Linux):
215
216* [user data dir] `~/.config/google-chrome`
217* [profile dir] `~/.config/google-chrome/Default`
218* [user cache dir] `~/.cache/google-chrome/Default`
219
220On Android, the user cache directory comes from
Steve Kobese26f53bd2017-07-06 00:15:02221[Context.getCacheDir](https://developer.android.com/reference/android/content/Context.html#getCacheDir%28%29).