Skip to content

Commit c172dd3

Browse files
authored
[release/10.0.1xx-preview2] Fix home calculation Fixes #46821 (#47292)
2 parents 29e7f86 + ff05ed0 commit c172dd3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Cli/dotnet/SudoEnvironmentDirectoryOverride.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@ public static void OverrideEnvironmentVariableToTmp(ParseResult parseResult)
3333
if (!OperatingSystem.IsWindows() && IsRunningUnderSudo() && IsRunningWorkloadCommand(parseResult))
3434
{
3535
string sudoHome = PathUtilities.CreateTempSubdirectory();
36-
var homeBeforeOverride = Path.Combine(Environment.GetEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName));
36+
var homeBeforeOverride = Environment.GetEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName);
3737
Environment.SetEnvironmentVariable(CliFolderPathCalculator.DotnetHomeVariableName, sudoHome);
3838

39-
CopyUserNuGetConfigToOverriddenHome(homeBeforeOverride);
39+
if (homeBeforeOverride is not null)
40+
{
41+
CopyUserNuGetConfigToOverriddenHome(homeBeforeOverride);
42+
}
4043
}
4144
}
4245

4346
/// <summary>
4447
/// To make NuGet honor the user's NuGet config file.
45-
/// Copying instead of using the file directoy to avoid existing file being set higher permission
48+
/// Copying instead of using the file directly to avoid existing file being set higher permission
4649
/// Try to delete the existing NuGet config file in "/tmp/dotnet_sudo_home/"
4750
/// to avoid different user's NuGet config getting mixed.
4851
/// </summary>

0 commit comments

Comments
 (0)