Error "path1 cannot be null" when invoking "dotnet run" on Linux when HOME is not set
See original GitHub issueSteps 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:
- Created 7 years ago
- Reactions:12
- Comments:20 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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:
The call to
dotnet run
fails with the following callstack:dotnet --info
: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