On Linux, invoke "dotnet run" when HOME is not set. My specific scenario was invoking "dotnet run" from an Upstart job.
Works correctly or displays friendly error message.
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)
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
Thanks @mikeharder
Every launch the supervisor crashing, three weeks could not understand the reason
bananapi
Operating System: Debian GNU/Linux stretch/sid
Kernel: Linux 3.4.104+
Architecture: arm
It requires nuget package to be in home for some reason. e.g. /home/{user}/.nuget/packages that's why it's dependant on this env variable.
Just verified this still repros on preview3 on OS X. Fix should be easy. The dependency exists when validating or prepping the offline nuget cache.
@piotrpMSFT is there any workaround for this?
@inormis IIRC setting the Home environment variable works around this issue
@droyad could you elaborate more on this?
As OP mentions, this issue occurs when the HOME environment variable is not set. Setting it works around the issue.
@droyad Home is set to /home/teamcity. Should it be set to something else?
Maybe it's related to https://github.com/dotnet/cli/issues/354
I'm getting the same error message on Windows whether or not HOME is set.
@PeterVenable can you provide more details? Which version of the tools are you using?
DotNetCore.1.0.1-VS2016Tools.Preview2.0.3 and dotnet-dev-win-x64.1.0.0-preview2-003156 were installed. Unfortunately I don't have login access to the machine where the error occurred so it's hard to provide more details.
@PeterVenable thanks for the context. As your version number and the callstack above suggest, this was an issue in the project.json back-end. The issue got resolved when we moved to MSBuild in preview3. We don't have plans to ship additional project.json updates now that we've transitioned to msbuild. Closing the issue, therefore.
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
I was able to workaround the issue by adding the following to my upstart script:
env NUGET_HTTP_CACHE_PATH=/home/<username>/.local/share/NuGet/v3-cache
@livarcocc can you take a look?
Same problem on 1.0.1, and none of the workarounds work
NUGET_PACKAGES=/root/.nuget/packages
NUGET_HTTP_CACHE_PATH=/root/.local/share/NuGet/v3-cache
are set in env
Unhandled Exception: System.ArgumentNullException: Value cannot be null.
Parameter name: path1
at System.IO.Path.Combine(String path1, String path2)
at NuGet.Common.NuGetEnvironment.GetFolderPath(NuGetFolderPath folder)
at NuGet.Configuration.SettingsUtility.GetGlobalPackagesFolder(ISettings set$
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.ShouldPrimeNuget$
at Microsoft.DotNet.Configurer.DotnetFirstTimeUseConfigurer.Configure()
at Microsoft.DotNet.Cli.Program.ConfigureDotNetForFirstTimeUse(INuGetCacheSe$
at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry teleme$
at Microsoft.DotNet.Cli.Program.Main(String[] args)
The fact that this is happening during first run is just because that's the first time we try to use these nuget apis. If you disabled first run, you will still hit issues when doing a regular restore, for instance.
I am moving the issue over to NuGet. @emgarten, let me know if we are using this API incorrect, in which case we can change it, but we have seen this issue before where the only way to get NuGet to work is to set HOME.
This issue was moved to NuGet/Home#5085
My build agent is Bamboo runs on Windows server 2012. I have the same problem.
After compared environment variables with my local login with the build agent, I set the following parameters before the dotnet restore, and it works.
set HOMEPATH=%USERPROFILE%
set APPDATA=%USERPROFILE%\AppData\Roaming
set LOCALAPPDATA=%USERPROFILE%\AppData\Local
Most helpful comment
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:
The call to
dotnet runfails with the following callstack:dotnet --info: