Home: dotnet restore failed : Unable to load the service index for source https://api.nuget.org/v3/index.json.

Created on 18 Apr 2017  路  11Comments  路  Source: NuGet/Home

Details about Problem

NuGet product used (dotnet nuget):

NuGet version (NuGet Command Line 4.0.0.0):

dotnet --version (if appropriate): 1.0.1

OS version (i.e. win10 v1607 (14393.321)):

dotnet --info
.NET Command Line Tools (1.0.1)

Product Information:
Version: 1.0.1
Commit SHA-1 hash: 005db40cd1

Runtime Environment:
OS Name: ubuntu
OS Version: 16.04
OS Platform: Linux
RID: ubuntu.16.04-x64
Base Path: /home/google/.dotnet/sdk/1.0.1

Worked before? If so, with which NuGet version:

Yes, works on previous version of dotnet (project.json)

Detailed repro steps so we can see the same problem

  1. create standard template : dotnet new mvc

  2. try to add package : dotnet add package Newtonsoft.Json

Output :

Microsoft (R) Build Engine version 15.1.548.43366
Copyright (C) Microsoft Corporation. All rights reserved.

Writing /tmp/tmpi0mDf1.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project '/var/lib/jenkins/workspace/www/www.csproj'.
log : Restoring packages for /var/lib/jenkins/workspace/www/www.csproj...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error: The type initializer for 'System.Net.Http.CurlHandler' threw an exception.
error: The type initializer for 'Http' threw an exception.
error: The type initializer for 'HttpInitializer' threw an exception.
error: Unable to load DLL 'System.Net.Http.Native': The specified module could not be found.
error: (Exception from HRESULT: 0x8007007E)

Other suggested things

if you will try add manually this package in *.csproj file
command : dotnet restore - will be failed with error: Unable to load the service index for source https://api.nuget.org/v3/index.json.

PS ^ this error behaviour the same for many others packages witch not start like Microsoft.*

And error not informative :(

image

Very helpful if you can zip a project and paste into this issue!

Most helpful comment

I found fix!
when we install libcurl3
from : https://launchpad.net/ubuntu/xenial/amd64/libcurl3/7.47.0-1ubuntu2.2
relay on yours arh server (for my ubuntu server it was amd64)
and after that this error with 'dotnet restore' disappear.

All 11 comments

this error behaviour the same for many others packages witch not start like Microsoft.*

Are any packages being restored?

It looks like the issue is in System.Net.Http. NuGet restore uses HttpClient from the framework.

Yes, restored only if packages start from Microsoft.*
like : Microsoft.AspNetCore.Server.Kestrel, Microsoft.AspNetCore.Diagnostics, etc.

just if you create new project and call 'dotnet restore' - this action will be execute OK

I found fix!
when we install libcurl3
from : https://launchpad.net/ubuntu/xenial/amd64/libcurl3/7.47.0-1ubuntu2.2
relay on yours arh server (for my ubuntu server it was amd64)
and after that this error with 'dotnet restore' disappear.

That is extremely odd that some packages download and not others! Glad you were able to find the fix, I will keep it in mind if anyone else hits this.

I've also experienced the same issue. I've got the curl version specified in the marked solution but it's still not working correctly.

Hi, BenjaminHolland
you can try to install last curl from https://curl.haxx.se/ this helps too
or https://www.howtoinstall.co/en/ubuntu/xenial/curl

I just encountered this as well. Running apt-get install libcurl3 addressed the issue for me. Thanks @KaBaJIeP!

I found how to fix!
when we install sudo apt install libcurl3
from : https://launchpad.net/ubuntu/xenial/amd64/libcurl3/7.47.0-1ubuntu2.2
relay on yours arh server (for my linux mint 18.2 it was amd64)
and after that this error with 'dotnet restore' disappear.
Its solved to me, thanks, KaBaJIeP .

any inputs on how to configure in Windows 10 environment if faced with a similar issue?

any inputs on how to configure in Windows 10 environment if faced with a similar issue?

Im having the same problem on Windows 10, could you find the solution?

If nuget.org is not accessible from your machine, please follow instructions currently located here: https://docs.microsoft.com/en-us/nuget/nuget-org/nuget-org-faq#nugetorg-not-accessible

Was this page helpful?
0 / 5 - 0 ratings