microsoft/aspire · error · InvalidOperationException

Browser user data directory

Error message

Browser user data directory '{0}' was not found.

What it means

ChromiumBrowserResolver.ResolveProfileDirectory validates that the supplied browser user data directory exists on disk before searching for a profile. If Directory.Exists(userDataDirectory) is false, it throws this InvalidOperationException naming the missing directory, because profile resolution is impossible without the user data root.

Solutions

  1. Verify the user data directory path (e.g., %LOCALAPPDATA%/Google/Chrome/User Data on Windows, ~/.config/google-chrome on Linux) before resolving.
  2. Launch the Chromium browser once so it creates its user data directory.
  3. Confirm the correct browser product's data directory is being passed.
  4. Pre-create or validate the directory with Directory.Exists and fail early with a clear message.

Example fix

// before
var dir = resolver.ResolveProfileDirectory("/home/user/.config/chrome", "Default");
// after
var userData = OperatingSystem.IsWindows()
    ? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Google", "Chrome", "User Data")
    : Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".config", "google-chrome");
if (!Directory.Exists(userData)) throw new DirectoryNotFoundException(userData);
var dir = resolver.ResolveProfileDirectory(userData, "Default");
Defensive patterns

Strategy: validation

Validate before calling

if (!Directory.Exists(userDataDirectory))
{
    throw new DirectoryNotFoundException($"Browser user data directory missing: {userDataDirectory}");
}

Try / catch

try
{
    var dir = resolver.ResolveProfileDirectory(userData, profile);
}
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Browser user data directory"))
{
    logger.LogError("User data directory '{Dir}' not found — launch the browser once first.", userData);
}

Prevention

When it happens

Trigger: Calling ResolveProfileDirectory with a userDataDirectory path that does not exist (typo, deleted profile, wrong OS-specific path, fresh machine where Chromium never ran).

Common situations: Hardcoding a Chrome user data path like ~/.config/google-chrome on Windows; pointing at a brand-new machine where the browser has never launched; user deleted or migrated the profile directory.

Related errors


AI-assisted analysis of microsoft/aspire@25830f84bd (2026-09-16). Data as JSON: /api/errors/1a0af04a66d3a106. Report an issue: GitHub.

Appendix: source

Thrown at src/Aspire.Hosting.Browsers/ChromiumBrowserResolver.cs:59

            {
                return resolvedPath;
            }
        }

        return PathLookupHelper.FindFullPathFromPath(browser);
    }

    /// <summary>
    /// Resolves a Chromium profile directory name from a directory name, profile display name, or shortcut name.
    /// </summary>
    internal static string ResolveProfileDirectory(string userDataDirectory, string profile)
    {
        ArgumentException.ThrowIfNullOrWhiteSpace(userDataDirectory);
        ArgumentException.ThrowIfNullOrWhiteSpace(profile);

        if (!Directory.Exists(userDataDirectory))
        {
            throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, BrowserMessageStrings.BrowserLogsUserDataDirectoryNotFound, userDataDirectory));
        }

        if (TryResolveProfileDirectoryFromDirectoryEntries(userDataDirectory, profile) is { } directMatch)
        {
            return directMatch;
        }

        // Chromium stores profile metadata in the user-data-root "Local State" file under profile.info_cache. Directory
        // names like "Default" or "Profile 1" are stable command-line values, while "name" and "shortcut_name" are
        // user-facing labels that can be renamed in the browser UI.
        //
        // Relevant Local State shape:
        // {
        //   "profile": {
        //     "info_cache": {
        //       "Default": { "name": "Person 1", "shortcut_name": "Person 1" },
        //       "Profile 1": { "name": "Work", "shortcut_name": "Work" }
        //     }

View on GitHub (pinned to 25830f84bd)