Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Unable to retrieve package list Mac OS. #574

Closed
jbvirt opened this issue Sep 27, 2023 · 12 comments · Fixed by #575
Closed

Unable to retrieve package list Mac OS. #574

jbvirt opened this issue Sep 27, 2023 · 12 comments · Fixed by #575

Comments

@jbvirt
Copy link

jbvirt commented Sep 27, 2023

Description

I just added NuGetForUnity to a new project on Mac and am getting this error when trying to view the package list.

Unable to retrieve package list from https://api.nuget.org/v3/index.jsonSearch()?$filter=IsLatestVersion&$orderby=DownloadCount desc&$skip=0&$top=15&searchTerm=''&targetFramework=''&includePrerelease=false
System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/Users/jbvirt/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe', CommandLine='-uri "https://api.nuget.org/v3"', CurrentDirectory='', Native error= Cannot find the specified file
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002f9] in <7b6d8d819f484934aae999cadeaf7aa9>:0 
  at System.Diagnostics.Process.Start () [0x0003a] in <7b6d8d819f484934aae999cadeaf7aa9>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at NugetForUnity.NugetHelper.GetCredentialFromProvider_Uncached (System.Uri feedUri, System.Boolean downloadIfMissing) [0x0016c] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetHelper.cs:1667 
  at NugetForUnity.NugetHelper.GetCredentialFromProvider (System.Uri feedUri) [0x0000f] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetHelper.cs:1577 
  at NugetForUnity.NugetHelper.RequestUrl (System.String url, System.String userName, System.String password, System.Nullable`1[T] timeOut) [0x00062] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetHelper.cs:1350 
  at NugetForUnity.NugetPackageSource.GetPackagesFromUrl (System.String url, System.String username, System.String password) [0x00026] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetPackageSource.cs:394 
  at NugetForUnity.NugetPackageSource.Search (System.String searchTerm, System.Boolean includeAllVersions, System.Boolean includePrerelease, System.Int32 numberToGet, System.Int32 numberToSkip) [0x000cd] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetPackageSource.cs:284 
UnityEngine.Debug:LogErrorFormat (string,object[])
NugetForUnity.NugetPackageSource:Search (string,bool,bool,int,int) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetPackageSource.cs:288)
NugetForUnity.NugetHelper:Search (string,bool,bool,int,int) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetHelper.cs:886)
NugetForUnity.NugetWindow:UpdateOnlinePackages () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetWindow.cs:357)
NugetForUnity.NugetWindow:Refresh (bool) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetWindow.cs:326)
NugetForUnity.NugetWindow:OnEnable () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetWindow.cs:289)
UnityEditor.EditorWindow:GetWindow<NugetForUnity.NugetWindow> ()
NugetForUnity.NugetWindow:DisplayNugetWindow () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@f9fb82dbaa/Editor/NugetWindow.cs:165)
  • NuGet Package: N/A
  • NuGetForUnity Version: v3.1.3
  • Unity Version: 2022.3.9f1 (Apple Silicon)
  • Operating System: Mac OS Sonoma 14 (M1)
@JoC0de
Copy link
Collaborator

JoC0de commented Sep 27, 2023

Not sure what you have configured but the base URL is a API version 3 but from the trace I can see that you are using the NuGetForUnity version that only supports API version 2. The NuGetForUnity version that support API version 3 is currently in "beta".
Your issue can be solved by deleting the NuGet.config so it gets recreated with the correct default values.

@jbvirt
Copy link
Author

jbvirt commented Sep 27, 2023

Thank you for the reply, however this happened in a fresh project, and also happens with the head version of NuGetForUnity as well as v3.1.3. Are you saying that these versions don't have any support for v3 on Mac? Because they work fine on Windows.

The default NuGet path that is configured fro nuget.org is: https://api.nuget.org/v3/index.json
The old API path at https://www.nuget.org/api/v2/ no longer seems to return any packages. Edit: I see, it's just old and confusing.

From the error, it looks like NuGet For Unity is trying to run a Windows .exe on mac.

@jbvirt
Copy link
Author

jbvirt commented Sep 27, 2023

I get the same type of error even on v3.0.5 and using the v2 NuGet API:

Unable to retrieve package from https://www.nuget.org/api/v2/Packages(Id='System.Runtime.CompilerServices.Unsafe',Version='6.0.0')
System.ComponentModel.Win32Exception (0x80004005): ApplicationName='/Users/jbvirt/.local/share/Nuget/CredentialProviders/CredentialProvider.VSS.exe', CommandLine='-uri "https://www.nuget.org/api/v2"', CurrentDirectory='', Native error= Cannot find the specified file
  at System.Diagnostics.Process.StartWithCreateProcess (System.Diagnostics.ProcessStartInfo startInfo) [0x002f9] in <7b6d8d819f484934aae999cadeaf7aa9>:0 
  at System.Diagnostics.Process.Start () [0x0003a] in <7b6d8d819f484934aae999cadeaf7aa9>:0 
  at (wrapper remoting-invoke-with-check) System.Diagnostics.Process.Start()
  at NugetForUnity.NugetHelper.GetCredentialFromProvider_Uncached (System.Uri feedUri, System.Boolean downloadIfMissing) [0x0016c] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1896 
  at NugetForUnity.NugetHelper.GetCredentialFromProvider (System.Uri feedUri) [0x0000f] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1806 
  at NugetForUnity.NugetHelper.RequestUrl (System.String url, System.String userName, System.String password, System.Nullable`1[T] timeOut) [0x00062] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1508 
  at NugetForUnity.NugetPackageSource.GetPackagesFromUrl (System.String url, System.String username, System.String password) [0x00026] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetPackageSource.cs:367 
  at NugetForUnity.NugetPackageSource.GetSpecificPackage (NugetForUnity.NugetPackageIdentifier package) [0x00074] in ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetPackageSource.cs:194 
UnityEngine.Debug:LogErrorFormat (string,object[])
NugetForUnity.NugetPackageSource:GetSpecificPackage (NugetForUnity.NugetPackageIdentifier) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetPackageSource.cs:198)
NugetForUnity.NugetHelper:GetOnlinePackage (NugetForUnity.NugetPackageIdentifier) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1165)
NugetForUnity.NugetHelper:GetSpecificPackage (NugetForUnity.NugetPackageIdentifier) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1084)
NugetForUnity.NugetHelper:InstallIdentifier (NugetForUnity.NugetPackageIdentifier,bool) (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1231)
NugetForUnity.NugetHelper:Restore () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:1563)
NugetForUnity.NugetHelper:.cctor () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetHelper.cs:149)
NugetForUnity.NugetPackageAssetPostprocessor:GetNuGetRepositoryPath () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetPackageAssetPostprocessor.cs:104)
NugetForUnity.NugetPackageAssetPostprocessor:OnPreprocessAsset () (at ./Library/PackageCache/com.github-glitchenzo.nugetforunity@620a6ce1e3/Editor/NugetPackageAssetPostprocessor.cs:46)
UnityEditor.AssetPostprocessingInternal:PreprocessAsset () (at /Users/bokken/build/output/unity/unity/Editor/Mono/AssetPostprocessor.cs:716)

Yet https://www.nuget.org/api/v2/Packages(Id='System.Runtime.CompilerServices.Unsafe',Version='6.0.0') very much exists.

@jbvirt
Copy link
Author

jbvirt commented Sep 27, 2023

I also get this error using the CLI tool:

Unable to retrieve package from https://www.nuget.org/api/v2/Packages(Id='System.Runtime.CompilerServices.Unsafe',Version='6.0.0')
System.NotSupportedException: No data is available for encoding 850. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.
   at System.Text.Encoding.GetEncoding(Int32 codepage)
   at NugetForUnity.NugetHelper.GetCredentialFromProvider_Uncached(Uri feedUri, Boolean downloadIfMissing) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetHelper.cs:line 1666
   at NugetForUnity.NugetHelper.GetCredentialFromProvider(Uri feedUri) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetHelper.cs:line 1577
   at NugetForUnity.NugetHelper.RequestUrl(String url, String userName, String password, Nullable`1 timeOut) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetHelper.cs:line 1350
   at NugetForUnity.NugetPackageSource.GetPackagesFromUrl(String url, String username, String password) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetPackageSource.cs:line 394
   at NugetForUnity.NugetPackageSource.GetSpecificPackage(NugetPackageIdentifier package) in /home/runner/work/NuGetForUnity/NuGetForUnity/src/NuGetForUnity/Editor/NugetPackageSource.cs:line 211
Could not find System.Runtime.CompilerServices.Unsafe 6.0.0 or greater.

@JoC0de
Copy link
Collaborator

JoC0de commented Sep 28, 2023

The error seems to come from

process.StartInfo.StandardOutputEncoding = Encoding.GetEncoding(850);

It uses a encoding that is only available on windows.
But normally the code should not run, if you don't have a credential provider lying around on your Mac. It searches in the environment variable NUGET_CREDENTIALPROVIDERS_PATH and in the Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Nuget", "CredentialProviders")). So if you delete the files inside this folders it should work.

@jbvirt
Copy link
Author

jbvirt commented Sep 28, 2023

Thanks, renaming/deleting that file seemed to fix both issues. There definitely should be a check to verify that the file is actually executable before using it.

It seems that NuGetForUnity keeps regenerating that file as well.

@jbvirt
Copy link
Author

jbvirt commented Sep 28, 2023

Yeah the issue is that CredentialProvider.VSS.exe is constantly regenerated and attempted to be used on mac.

@JoC0de
Copy link
Collaborator

JoC0de commented Sep 28, 2023

As far as I can see the file isn't downloaded / created it already exists. It is only downloaded if you use azure package source.

@jbvirt
Copy link
Author

jbvirt commented Sep 28, 2023

That would partially explain it then, we do use a package from: https://pkgs.dev.azure.com/UnityDeveloperTools/MSBuildForUnity/_packaging/UnityDeveloperTools/nuget/v2/

Then I guess the simplest fix would be to check if CredentialProvider.VSS.exe is actually executable on the provided os (check for executable flag).
I was able to work around this issue consistently by just changing the owner of the CredentialProvider's folder to be root.

@JoC0de
Copy link
Collaborator

JoC0de commented Oct 1, 2023

I fixed the issue in #575. I don't have a Mac to test if it works, so it would be nice if you can test if it fixes the issue? You can install it using the .unitypackage build by the Github Action or by installing the package from the PR branch using UPM Git-Url.

@jbvirt
Copy link
Author

jbvirt commented Oct 2, 2023

This seems to have fixed the issues, thanks!

@jbvirt jbvirt closed this as completed Oct 2, 2023
@JoC0de
Copy link
Collaborator

JoC0de commented Oct 3, 2023

@jbvirt Thanks for testing

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

Successfully merging a pull request may close this issue.

2 participants