-
Notifications
You must be signed in to change notification settings - Fork 375
Description
Description
I have been running this tool inside of a GitHub action and it has worked great, but we recently switched to using Kubernetes runners and suddenly this action started crashing with the error:
Unhandled exception. System.TypeInitializationException: The type initializer for 'NugetForUnity.NugetHelper' threw an exception.
---> System.ArgumentException: The value cannot be an empty string. (Parameter 'path')
at System.ArgumentException.ThrowNullOrEmptyException(String argument, String paramName)
at System.IO.Path.GetFullPath(String path)
at NugetForUnity.NugetHelper..cctor() in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetHelper.cs:line 56
--- End of inner exception stack trace ---
at NugetForUnity.NugetHelper.set_InstallDependencies(Boolean value) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetHelper.cs:line 111
at NuGetForUnity.Cli.Program.Main(String[] args) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity.Cli/Program.cs:line 55
The cause from the issue seems to be this line that is looking to get the Path.GetFullPath of Environment.SpecialFolder.LocalApplicationData. The error is caused when the LocalApplicationData folder is null or empty. This can occur in some situations where the tool is being run by the root user on Linux.
It seems like the issue will still occur in the latest version in PackageCacheManager.cs.
A workaround was to export the environment variable XDG_DATA_HOME as documented here, and make sure that the folder exists.
However, there still should either be a fallback cache path or this exception should be properly handled so that it is clear what the issue is.
- NuGetForUnity.Cli Version: 3.1.3
- Unity Version: N/A
- Operating System: Linux Container
mcr.microsoft.com/dotnet/sdk:7.0