microsoft/aspire · error · InvalidOperationException

Unable to determine installation directory from

Error message

Unable to determine installation directory from: {currentExePath}

What it means

A follow-up failure in the archive self-update path: the executable path was known but `Path.GetDirectoryName` returned null or empty, meaning the executable path had no directory component (e.g. a bare name or rootless path). The CLI cannot compute the installation directory to replace the binary in, so it throws.

Solutions

  1. Ensure the CLI is launched via its full absolute path (e.g. /usr/local/bin/aspire)
  2. Reinstall the CLI with the official installer so the executable lives at a normal absolute path
  3. Avoid stubbing or overriding the process path provider in ways that return directory-less paths
Defensive patterns

Strategy: try-catch

Validate before calling

var exePath = Environment.ProcessPath;
if (string.IsNullOrEmpty(Path.GetDirectoryName(exePath)))
    Console.Error.WriteLine($"Executable path '{exePath}' has no directory component; self-update unsupported.");

Type guard

bool hasInstallDir => Path.GetDirectoryName(Environment.ProcessPath) is { Length: > 0 };

Try / catch

try { await UpdateSelfAsync(); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unable to determine installation directory"))
{ Console.Error.WriteLine("Reinstall the CLI at a normal absolute path."); }

Prevention

When it happens

Trigger: `aspire update --self` when the current executable path is malformed or relative without a directory, or the process path provider returns a value like just 'aspire' without any path separator.

Common situations: Custom process-path provider stubs in tests, exotic sandboxes reporting abbreviated executable paths, or corrupted launch environments.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/Aspire.Cli/Commands/UpdateCommand.cs:761

            return CommandResult.Failure(CliExitCodes.InvalidCommand, errorMessage);
        }
    }

    private async Task ExtractAndUpdateAsync(string archivePath, string channel, CancellationToken cancellationToken)
    {
        // Archive self-update is a same-directory replacement, not an installer that searches
        // for a writable fallback. If the executable is package-manager-owned, installing
        // elsewhere would leave the user's PATH/profile pointing at the old package-managed CLI.
        var currentExePath = _processPathProvider.ProcessPath;
        if (string.IsNullOrEmpty(currentExePath))
        {
            throw new InvalidOperationException("Unable to determine current CLI location.");
        }

        var installDir = Path.GetDirectoryName(currentExePath);
        if (string.IsNullOrEmpty(installDir))
        {
            throw new InvalidOperationException($"Unable to determine installation directory from: {currentExePath}");
        }

        var exeName = _environment.IsWindows() ? "aspire.exe" : "aspire";
        var targetExePath = Path.Combine(installDir, exeName);
        var tempExtractDir = Directory.CreateTempSubdirectory("aspire-cli-extract").FullName;

        try
        {
            // Extract archive
            await InteractionService.ShowStatusAsync(
                UpdateCommandStrings.ExtractingNewCli,
                async () =>
                {
                    await ArchiveHelper.ExtractAsync(archivePath, tempExtractDir, _environment, cancellationToken);
                    return 0;
                },
                KnownEmojis.Package);

View on GitHub (pinned to 25830f84bd)