sdk: Error "path1 cannot be null" when invoking "dotnet run" on Linux when HOME is not set

Steps to reproduce

On Linux, invoke “dotnet run” when HOME is not set. My specific scenario was invoking “dotnet run” from an Upstart job.

Expected behavior

Works correctly or displays friendly error message.

Actual behavior

System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at Microsoft.DotNet.ProjectModel.Resolution.PackageDependencyProvider.ResolvePackagesPath(String rootDirectory, Globa
lSettings settings)
   at Microsoft.DotNet.ProjectModel.ProjectContextBuilder.Build()
   at Microsoft.DotNet.ProjectModel.ProjectContext.<CreateContextForEachFramework>d__32.MoveNext()
   at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source)
   at Microsoft.DotNet.Tools.Run.RunCommand.CalculateDefaultsForNonAssigned()
   at Microsoft.DotNet.Tools.Run.RunCommand.RunExecutable()
   at Microsoft.DotNet.Tools.Run.RunCommand.Start()
   at Microsoft.DotNet.Tools.Run.RunCommand.Run(String[] args)

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-beta-002275)

Product Information:
 Version:     1.0.0-beta-002275
 Commit Sha:  4af7437aa6

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  14.04
 OS Platform: Linux
 RID:         ubuntu.14.04-x64

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 12
  • Comments: 20 (9 by maintainers)

Most upvoted comments

I’m seeing a similar issue with CLI 1.0.0-rc4-004757, though it appears the root cause has moved from the CLI to NuGet.

My upstart script contains the following:

env NUGET_PACKAGES=/home/<username>/.nuget/packages
exec /home/<username>/.dotnet/dotnet run -p /home/<username>/<project>.csproj

The call to dotnet run fails with the following callstack:

Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2, String path3)
   at NuGet.Common.NuGetEnvironment.GetFolderPath(SpecialFolder folder)
   at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder)
   at NuGet.Configuration.SettingsUtility.GetHttpCacheFolder()
   at NuGet.Configuration.NuGetPathContext.Create(ISettings settings)
   at Microsoft.DotNet.Configurer.NuGetCacheSentinel.get_NuGetCachePath()
   at Microsoft.DotNet.Configurer.NuGetCacheSentinel.Exists()
   at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.ShouldPrimeNugetCache()
   at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
   at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSentinel nugetCacheSentinel)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

dotnet --info:

.NET Command Line Tools (1.0.0-rc4-004757)

Product Information:
 Version:            1.0.0-rc4-004757
 Commit SHA-1 hash:  f69f0ed266

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  14.04
 OS Platform: Linux
 RID:         ubuntu.14.04-x64
 Base Path:   /home/<username>/.dotnet/sdk/1.0.0-rc4-004757