Skip to content

Commit

Permalink
CompilerInstallation fix: Remove existing alternatives for cpp (#396)
Browse files Browse the repository at this point in the history
* Added line to remove existing alternatives for cpp.

* Fixing CompilerInstallation test.

* Removing existing duplicate command.

---------

Co-authored-by: saibulusu <saibulusu@microsoft.com>
  • Loading branch information
saibulusu and saibulusu authored Nov 8, 2024
1 parent 5f82099 commit 04cb9cb
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ private async Task RemoveAlternativesAsync(EventContext telemetryContext, Cancel
string[] packages =
{
"gcc",
"gfortran",
"cpp"
"gfortran"
};

// due to the following error:
Expand All @@ -264,7 +263,7 @@ private async Task RemoveAlternativesAsync(EventContext telemetryContext, Cancel
}
}
}

private async Task SetGccPriorityAsync(string gccVersion, EventContext telemetryContext, CancellationToken cancellationToken)
{
string updateAlternativeArgument = $"--install /usr/bin/gcc gcc /usr/bin/gcc-{gccVersion} {gccVersion}0 " +
Expand All @@ -276,6 +275,9 @@ private async Task SetGccPriorityAsync(string gccVersion, EventContext telemetry

await this.ExecuteCommandAsync("update-alternatives", updateAlternativeArgument, Environment.CurrentDirectory, telemetryContext, cancellationToken);

// Remove all existing alternatives for cpp before the subsequent "update-alternatives" of cpp
await this.ExecuteCommandAsync("update-alternatives", "--remove-all cpp", Environment.CurrentDirectory, telemetryContext, cancellationToken);

// For some update path, the cpp can't be update-alternative by a gcc, so needs a separate call.
string updateAlternativeArgumentCpp = $"--install /usr/bin/cpp cpp /usr/bin/cpp-{gccVersion} {gccVersion}0";

Expand Down

0 comments on commit 04cb9cb

Please sign in to comment.