Skip to content

Commit 034c8d9

Browse files
Forgindgithub-actions
authored andcommitted
Fix home calculation
1 parent 29e7f86 commit 034c8d9

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) ?? Environment.GetEnvironmentVariable("HOME");
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)