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

[bug] error NU1301 (Unable to load the service index for source https://api.nuget.org/v3/index.json.) when I am trying to create any .NET Application in Ubuntu 20.04 #12535

Closed
sevens7xix opened this issue Apr 11, 2023 · 8 comments

Comments

@sevens7xix
Copy link

NuGet Product Used

dotnet.exe

Product Version

dotnet-sdk-7.0.202

Worked before?

No response

Impact

None

Repro Steps & Context

  1. Step one keep Ubuntu 20.04 with all its dependencies updated
  2. Try to create any project that needs additional dependencies like https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-web-api?view=aspnetcore-3.1&tabs=visual-studio-code#create-a-web-project-3 or https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-csharp?tabs=in-process#create-an-azure-functions-project
  3. That it, when omnisharp or the dotnet sdk try to restore/build/run the project the following exception its handled error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

Verbose Logs

(in) RestoreGraphItems Count '7' (TaskId:39)
                     (in) RestoreDisableParallel 'False' (TaskId:39)
                     (in) RestoreNoCache 'False' (TaskId:39)
                     (in) RestoreIgnoreFailedSources 'False' (TaskId:39)
                     (in) RestoreRecursive 'True' (TaskId:39)
                     (in) RestoreForce 'False' (TaskId:39)
                     (in) HideWarningsAndErrors 'False' (TaskId:39)
                     (in) RestoreForceEvaluate 'False' (TaskId:39)
                     (in) RestorePackagesConfig 'False' (TaskId:39)
                     X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.202/trustedroots/codesignctl.pem'. (TaskId:39)
                     X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.202/trustedroots/timestampctl.pem'. (TaskId:39)
                     Running restore with 4 concurrent jobs. (TaskId:39)
                     Reading project file /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj. (TaskId:39)
                     The restore inputs for 'TodoApi' have changed. Continuing restore. (TaskId:39)
                     Restoring packages for /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj... (TaskId:39)
                     Restoring packages for .NETCoreApp,Version=v7.0... (TaskId:39)
11:06:51.525     1>/home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
11:06:51.533     1>/home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
                     Checking compatibility of packages on net7.0. (TaskId:39)
                     All packages and projects are compatible with net7.0. (TaskId:39)
                     Committing restore... (TaskId:39)
                     Writing assets file to disk. Path: /home/saroui/Documents/sample-app/TodoApi/obj/project.assets.json (TaskId:39)
                     Writing cache file to disk. Path: /home/saroui/Documents/sample-app/TodoApi/obj/project.nuget.cache (TaskId:39)
                     Persisting dg to /home/saroui/Documents/sample-app/TodoApi/obj/TodoApi.csproj.nuget.dgspec.json (TaskId:39)
                     Failed to restore /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (in 326 ms). (TaskId:39)
                      (TaskId:39)
                     NuGet Config files used: (TaskId:39)
                         /home/saroui/.nuget/NuGet/NuGet.Config (TaskId:39)
                      (TaskId:39)
                     Feeds used: (TaskId:39)
                         https://api.nuget.org/v3/index.json (TaskId:39)
                   Done executing task "RestoreTask" -- FAILED. (TaskId:39)
11:06:51.652     1>Done building target "Restore" in project "TodoApi.csproj" -- FAILED.: (TargetId:42)
11:06:51.658     1>Done Building Project "/home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj" (Restore target(s)) -- FAILED.
Deferred Messages
11:06:51.659     0>
Detailed Build Summary
======================
     (TaskId:0)
                     
                     ============================== Build Hierarchy (IDs represent configurations) =====================================================
                     Id                  : Exclusive Time   Total Time   Path (Targets)
                     ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
                     0                   : 1.627s           1.932s       /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (Restore)  (TaskId:0)
                     | 1                 : 0.077s           0.077s       /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (_IsProjectRestoreSupported)  (TaskId:0)
                     | 2                 : 0.009s           0.009s       /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (_GenerateRestoreProjectPathWalk)  (TaskId:0)
                     | 3                 : 0.196s           0.196s       /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (_GenerateRestoreGraphProjectEntry)  (TaskId:0)
                     . 4                 : 0.021s           0.021s       /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj (_GenerateProjectRestoreGraph)  (TaskId:0)
                     
                     ============================== Node Utilization (IDs represent configurations) ====================================================
                     Timestamp:            1        Duration   Cumulative
                     ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
                     638168260097250049:   0        0.905s     0.905s .................. (TaskId:0)
                     638168260106301983:   1        0.078s     0.983s . (TaskId:0)
                     638168260107081071:   0        0.041s     1.024s  (TaskId:0)
                     638168260107492220:   2        0.010s     1.034s  (TaskId:0)
                     638168260107587607:   0        0.019s     1.053s  (TaskId:0)
                     638168260107776373:   3        0.196s     1.249s ... (TaskId:0)
                     638168260109739325:   0        0.003s     1.252s  (TaskId:0)
                     638168260109766418:   4        0.021s     1.273s  (TaskId:0)
                     638168260109978266:   0        0.662s     1.935s ............. (TaskId:0)
                     -----------------------------------------------------------------------------------------------------------------------------------
                     Utilization:          100.0    Average Utilization: 100.0 (TaskId:0)

Project Evaluation Performance Summary:
      837 ms  /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj   2 calls

Project Performance Summary:
     1333 ms  /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj   6 calls
               1107 ms  Restore                                    1 calls
                  2 ms  _IsProjectRestoreSupported                 2 calls
                  8 ms  _GenerateRestoreProjectPathWalk            1 calls
                195 ms  _GenerateRestoreGraphProjectEntry          1 calls
                 21 ms  _GenerateProjectRestoreGraph               1 calls

Target Performance Summary:
        0 ms  _GenerateRestoreProjectPathItemsCurrentProject   1 calls
        0 ms  _GenerateProjectRestoreGraph               1 calls
        0 ms  _GetRestoreSettingsCurrentProject          1 calls
        0 ms  _GenerateRestoreDependencies               1 calls
        0 ms  _GenerateProjectRestoreGraphCurrentProject   1 calls
        0 ms  _GenerateRestoreGraphProjectEntry          1 calls
        0 ms  _CheckForObsoleteDotNetCliToolReferences   1 calls
        0 ms  _GetRestoreTargetFrameworkOverride         1 calls
        0 ms  _CheckForUnsupportedCppNETCoreVersion      2 calls
        0 ms  _CheckForLanguageAndFeatureCombinationSupport   1 calls
        0 ms  _GetProjectJsonPath                        1 calls
        0 ms  _GetRestoreSettingsPerFramework            1 calls
        0 ms  _CheckForUnsupportedNETCoreVersion         2 calls
        0 ms  _GetRestoreSettingsOverrides               1 calls
        0 ms  _IsProjectRestoreSupported                 1 calls
        1 ms  CollectFrameworkReferences                 1 calls
        1 ms  _GenerateRestoreSpecs                      1 calls
        1 ms  _GenerateRestoreProjectPathItems           1 calls
        1 ms  CollectCentralPackageVersions              1 calls
        1 ms  _CollectTargetFrameworkForTelemetry        1 calls
        2 ms  _GenerateRestoreProjectPathItemsPerFramework   1 calls
        3 ms  ApplyImplicitVersions                      1 calls
        3 ms  _GenerateDotnetCliToolReferenceSpecs       1 calls
        3 ms  _GetRestoreTargetFrameworksOutput          1 calls
        3 ms  _GenerateRestoreProjectSpec                1 calls
        3 ms  CollectPackageReferences                   1 calls
        3 ms  CheckForImplicitPackageReferenceOverrides   1 calls
        4 ms  _GenerateRestoreProjectPathWalk            1 calls
        5 ms  CollectPackageDownloads                    1 calls
        7 ms  _GenerateProjectRestoreGraphPerFramework   1 calls
        8 ms  _GetRestoreProjectStyle                    1 calls
       11 ms  UpdateAspNetToFrameworkReference           1 calls
       25 ms  _LoadRestoreGraphEntryPoints               1 calls
       30 ms  _GetAllRestoreProjectPathItems             1 calls
       34 ms  _GetRestoreSettings                        1 calls
      125 ms  ProcessFrameworkReferences                 1 calls
      153 ms  _FilterRestoreGraphProjectInputItems       1 calls
      227 ms  _GenerateRestoreGraph                      1 calls
      652 ms  Restore                                    1 calls

Task Performance Summary:
        1 ms  GetRestorePackageDownloadsTask             1 calls
        1 ms  AllowEmptyTelemetry                        1 calls
        1 ms  GetRestoreFrameworkReferencesTask          1 calls
        1 ms  ApplyImplicitVersions                      1 calls
        1 ms  GetRestoreProjectReferencesTask            1 calls
        1 ms  CheckForDuplicateFrameworkReferences       1 calls
        1 ms  GetRestorePackageReferencesTask            1 calls
        2 ms  GetRestoreDotnetCliToolsTask               1 calls
        2 ms  GetProjectTargetFrameworksTask             1 calls
        2 ms  NuGetMessageTask                           1 calls
        2 ms  ConvertToAbsolutePath                      2 calls
        2 ms  CheckForImplicitPackageReferenceOverrides   1 calls
        3 ms  Message                                    3 calls
        4 ms  GetRestoreProjectStyleTask                 1 calls
        5 ms  CheckIfPackageReferenceShouldBeFrameworkReference   2 calls
        5 ms  WarnForInvalidProjectsTask                 1 calls
        7 ms  RemoveDuplicates                           5 calls
        8 ms  CheckForDuplicateNuGetItemsTask            3 calls
       31 ms  ResolveAppHosts                            1 calls
       33 ms  GetRestoreSettingsTask                     1 calls
       89 ms  ProcessFrameworkReferences                 1 calls
      366 ms  MSBuild                                    6 calls
      651 ms  RestoreTask                                1 calls

Build FAILED.

                   "/home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj" (Restore target) (1) ->
                   (Restore target) -> 
                     /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.
                     /home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj : error NU1301: Unable to load the service index for source https://api.nuget.org/v3/index.json.

    0 Warning(s)
    2 Error(s)
@sevens7xix sevens7xix changed the title [bug] error NU1301 () when I am trying to create any .NET Application in Ubuntu 20.04 [bug] error NU1301 (Unable to load the service index for source https://api.nuget.org/v3/index.json.) when I am trying to create any .NET Application in Ubuntu 20.04 Apr 11, 2023
@kartheekp-ms
Copy link
Contributor

May be related to #5358. Is there any proxy configured in the environment?

Bing AI Chat suggests, you can check the proxy settings via the command line using the following steps:

- Open the Terminal application.
- Type the command "env | grep -i proxy" and press Enter. This will display the proxy settings for your system.
- If you see any proxy-related environment variables such as http_proxy, https_proxy, ftp_proxy, etc., it means a proxy is configured for your system.
- You can also check the contents of the /etc/environment file and the /etc/apt/apt.conf.d/proxy file to view the proxy settings in Ubuntu.

@kartheekp-ms kartheekp-ms added Functionality:Restore Product:dotnet.exe WaitingForCustomer Applied when a NuGet triage person needs more info from the OP Area:HttpCommunication and removed Triage:Untriaged labels Apr 12, 2023
@sevens7xix
Copy link
Author

Hey there, Thanks to answer to this issue, actually I check issue #5358 before and try everything suggested there but nothing solved the problem. Besides I checked "env | grep -i proxy" and "/etc/apt/apt.conf.d/proxy " and there isn't any proxy configured on my enviroment.

If it helps to unfog this problem, curl https://api.nuget.org/v3/index.json works perfectly and also I can access to the URL from multiple browsers without any problem.

I am going to stay tuned, Thank you very much beforehand!.

@ghost ghost added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Apr 12, 2023
@zivkan
Copy link
Member

zivkan commented Apr 12, 2023

Unfortunately NuGet isn't showing inner exceptions on these "unable to get service index" errors, making it hard to guess what the root cause was: #12530

From my own testing, dotnet add package does show the inner exception. So, can you please try dotnet add package NuGet.Protocol (or any other package you like), and you should see what the cause of the connection failure is.

@ghost ghost added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Apr 12, 2023
@sevens7xix
Copy link
Author

Thank you very much, now I can see what is the cause of the connection issue and its looks like some incompatibility with the kernel of my environment

info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.202/trustedroots/codesignctl.pem'.
info : X.509 certificate chain validation will use the fallback certificate bundle at '/usr/share/dotnet/sdk/7.0.202/trustedroots/timestampctl.pem'.
info : Adding PackageReference for package 'NuGet.Protocol' into project '/home/saroui/Documents/sample-app/TodoApi/TodoApi.csproj'.
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error:   The format of value '(Linux 6.2.10-1-liquorix-amd64 #1 ZEN SMP PREEMPT_DYNAMIC liquorix 6.2-13ubuntu1~focal (2023-04)' is invalid.

In theory its the last update of the kernel, and I just followed the steps on MS Docs to install de .NET SDK present on my environment. I would be glad to know if there is something I can do to fix the issue locally.

@ghost ghost added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Apr 12, 2023
@zivkan
Copy link
Member

zivkan commented Apr 12, 2023

This was a known issue, first reported a few months ago, but has been fixed in the main branch

The fix will be part of NuGet 6.6, which isn't out yet. But if you can use a preview .NET SDK 7.0.3xx, it should work. If you're using a version of the .NET SDK that is available as part of Ubuntu's package repository, that's using what .NET calls "source build", and for reasons I don't understand they limit to the 1xx versions of the SDK, which means it won't contain NuGet's fix until version 8.0.1xx. But if you can use the Microsoft package feed, then you can get newer versions of the .NET SDK (but possibly not previews): https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu

@ghost ghost added WaitingForCustomer Applied when a NuGet triage person needs more info from the OP and removed WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. labels Apr 12, 2023
@sevens7xix
Copy link
Author

Thank you, could you please show me how to get the .NET SDN 7.0.3xx because the latest release of .NET 7.0.5 includes .NET SDK 7.0.203, but I don't see any trace of the nightly builds.

Thank you beforehand!

@ghost ghost added WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. and removed WaitingForCustomer Applied when a NuGet triage person needs more info from the OP labels Apr 12, 2023
@kartheekp-ms
Copy link
Contributor

kartheekp-ms commented Apr 12, 2023

I don't see any trace of the nightly builds.

https://github.com/dotnet/installer/blob/main/README.md#table

I am closing this as a duplicate of #11995 that is already fixed.

@kartheekp-ms kartheekp-ms closed this as not planned Won't fix, can't repro, duplicate, stale Apr 12, 2023
@ghost ghost removed the WaitingForClientTeam Customer replied, needs attention from client team. Do not apply this label manually. label Apr 12, 2023
@kartheekp-ms kartheekp-ms added the Resolution:Duplicate This issue appears to be a Duplicate of another issue label Apr 12, 2023
@0xRaReddy
Copy link

Seeing this issue now in docker build.
It looks like both docker images mcr.microsoft.com/dotnet/sdk:7.0 and mcr.microsoft.com/dotnet/nightly/sdk:7.0 have dotnet sdk 7.0.203

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

No branches or pull requests

4 participants