question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
mikehardercommented, Feb 9, 2017

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
0reactions
kenhan168commented, Dec 13, 2017

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error "path1 cannot be null" when invoking "dotnet run" on ...
As OP mentions, this issue occurs when the HOME environment variable is not set. Setting it works around the issue.
Read more >
System.ArgumentNullException: Value cannot be null. ...
I'm trying to run a dotnet app using dotnet run --configuration Release at system server Startup/Reboot. I'm using a init.d script to ...
Read more >
Value cannot be null. (Parameter 'path1') at System.IO.Path ...
I create a sample project and using your code. I can reproduce the issue. You need change your code
Read more >
Why am I getting a "Value cannot be null (Parameter ' ...
The file is "appsettings.json" Im not adding the JSON file, I only need the connection string from it which is use a method....
Read more >
'value cannot be null. Parameter name: path'" and can any ...
Let me just explain what the error means: You have tried to use a variable, property, or a method return value but it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found