Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Can't refresh packages : Failed to initialize the source #693

Closed
SashelI opened this issue Jan 29, 2025 · 6 comments · Fixed by #701
Closed

Can't refresh packages : Failed to initialize the source #693

SashelI opened this issue Jan 29, 2025 · 6 comments · Fixed by #701

Comments

@SashelI
Copy link

SashelI commented Jan 29, 2025

Hi,

I am trying to use the package on a newly created project, on a Mac computer.

I get this error in Unity console when trying to refresh packages list :

Failed to initialize the NuGet package source 'https://api.nuget.org/v3/index.json'. Error: System.ComponentModel.Win32Exception 
(0x80004005): ApplicationName='dotnet', CommandLine=' 
/Users/unitycompany/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe -uri "https://api.nuget.org/v3/index.json"', 
CurrentDirectory='', Native error= Cannot find the specified file

(then followed by :)

Initialization of api client for 'https://api.nuget.org/v3/index.json' failed so we can't use it. error (cached): 
System.ComponentModel.Win32Exception (0x80004005): ApplicationName='dotnet', CommandLine=' 
/Users/unitycompany/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe -uri "https://api.nuget.org/v3/index.json"', 
CurrentDirectory='', Native error= Cannot find the specified file

Anyone knows why it is trying to execute a .exe file in a MacOS environment ? Or how to fix this ? Thanks

PS: trying to navigate to the file in a terminal works, so the path and the file are there

@JoC0de
Copy link
Collaborator

JoC0de commented Jan 31, 2025

What do you get when you type which dotnet inside your terminal? NugetForUnity should invoke the .exe using the dotnet CLI or alternatively using mono

@SashelI
Copy link
Author

SashelI commented Jan 31, 2025

What do you get when you type which dotnet inside your terminal? NugetForUnity should invoke the .exe using the dotnet CLI or alternatively using mono

Hi, I get /usr/local/share/dotnet/dotnet

@JoC0de
Copy link
Collaborator

JoC0de commented Jan 31, 2025

I don't have a mac to test.
The code should basically try to invoke the flowing command to run the .exe:

/usr/local/share/dotnet/dotnet /Users/unitycompany/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe -uri "https://api.nuget.org/v3/index.json"

See implementation:

else
{
// Linux or MacOS -> we need 'mono' / 'dotnet' to run the executable
if (dotNetExecutablePath == null)
{
dotNetExecutablePath = GetDotnetExecutablePath(outputEncoding);
}
executableToStart = dotNetExecutablePath;
executableArguments = $" {executableFilePath} {arguments}";
NugetLogger.LogVerbose("Changed command to call executable '{0}' with arguments '{1}'.", executableToStart, executableArguments);
}
return new ProcessStartInfo(executableToStart, executableArguments)
{
StandardOutputEncoding = outputEncoding, StandardErrorEncoding = outputEncoding,
};

The path to dotnet should be absolute you can verify it when you enable verbose logging. The error Cannot find the specified file sounds like it can't find dotnet.
Please test the command and lock at the verbose log to get to the source of the problem.

@SashelI
Copy link
Author

SashelI commented Feb 3, 2025

Hi,

This is what the command gives me in the terminal :

A fatal error was encountered. The library 'libhostpolicy.dylib' required to execute the application was not found in '/Users/unitycompany/.local/share/NuGet/CredentialProviders/'.
Failed to run as a self-contained app.
  - The application was run as a self-contained app because '/Users/unitycompany/.local/share/NuGet/CredentialProviders/CredentialProvider.VSS.runtimeconfig.json' was not found.
  - If this should be a framework-dependent app, add the '/Users/unitycompany/.local/share/NuGet/CredentialProviders/CredentialProvider.VSS.runtimeconfig.json' file and specify the appropriate framework.

And verbose logging says :

Changed command to call executable 'dotnet' with arguments ' /Users/unitycompany/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe -uri "https://api.nuget.org/v3/index.json"'.

(right before the error)

I am not usually a mac user myself, so I might just be dropping logs without fully understanding them myself :)

@JoC0de
Copy link
Collaborator

JoC0de commented Feb 3, 2025

Hi,

ok it is strange that the verbose log only contains dotnet instead of the absolute path.
But I don't see a issue in the code of NuGetForUnity. There was a similar issue #574 according to the issuer it worked after the fix.
The easiest way I can see is adding a option to stop NuGetForUnity from trying to using the CredentialProvider at all (we could also solve #245).
For a temporary fix you can delete the /Users/unitycompany/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe file so NuGetForUnity stops trying to use it.

@SashelI
Copy link
Author

SashelI commented Feb 4, 2025

Hi,

I see, thanks. Removing the file worked for the most part, I still have the error (and file regenerated) when trying to fetch an Azure package, but reading #574 I understand this is normal. At least I have the rest of packages, thanks.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants