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

Workflow fails to download dependencies from NuGet.org #3038

Closed
1 of 7 tasks
AaronVanGeffen opened this issue Mar 26, 2021 · 66 comments
Closed
1 of 7 tasks

Workflow fails to download dependencies from NuGet.org #3038

AaronVanGeffen opened this issue Mar 26, 2021 · 66 comments

Comments

@AaronVanGeffen
Copy link

Description
For the OpenLoco project, we gratefully make use of GitHub Actions for our CI. To this end, we set up a workflow for our Windows CI:
https://github.com/OpenLoco/OpenLoco/blob/master/.github/workflows/ci.yml#L18-L59

The Visual Studio project this workflow builds has been set up to depend on a package from NuGet.org:
https://github.com/OpenLoco/OpenLoco/blob/master/src/OpenLoco/openloco.vcxproj#L352-L354
https://www.nuget.org/packages/openloco.dependencies

This workflow worked fine until two days ago. However, we have noticed the package no longer gets retrieved properly, causing most (but not all) runs to fail.

Area for Triage:
C/C++

Question, Bug, or Feature?:
Bug

Virtual environments affected

  • Ubuntu 16.04
  • Ubuntu 18.04
  • Ubuntu 20.04
  • macOS 10.15
  • macOS 11.0
  • Windows Server 2016 R2
  • Windows Server 2019

Image version
20210321.1 (broken)
20210316.1 (fine)

Expected behavior
Successful run on image version 20210316.1, 3 days ago
https://github.com/OpenLoco/OpenLoco/runs/2181845951

Restore:
  Restoring packages for D:\a\OpenLoco\OpenLoco\src\OpenLoco\openloco.vcxproj...
    GET https://api.nuget.org/v3-flatcontainer/openloco.dependencies/index.json
    OK https://api.nuget.org/v3-flatcontainer/openloco.dependencies/index.json 173ms
    GET https://api.nuget.org/v3-flatcontainer/openloco.dependencies/1.3.0/openloco.dependencies.1.3.0.nupkg
    OK https://api.nuget.org/v3-flatcontainer/openloco.dependencies/1.3.0/openloco.dependencies.1.3.0.nupkg 105ms
  Installed OpenLoco.Dependencies 1.3.0 from https://api.nuget.org/v3/index.json with content hash 2kTdy9fJCCYiCDi5QPxbJQ8st/7AfT+gt+rjAz++yONLyxOIBQbdk2g5Oqv5VSU/UAPZ8BrNSanNdxcYDszkFA==.
  Committing restore...
  Generating MSBuild file D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\openloco.vcxproj.nuget.g.props.
  Generating MSBuild file D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\openloco.vcxproj.nuget.g.targets.
  Writing assets file to disk. Path: D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\project.assets.json
  Restored D:\a\OpenLoco\OpenLoco\src\OpenLoco\openloco.vcxproj (in 7.18 sec).

Actual behavior
Failed run on 20210321.1 today:
https://github.com/OpenLoco/OpenLoco/runs/2204773635

Restore:
  Restoring packages for D:\a\OpenLoco\OpenLoco\src\OpenLoco\openloco.vcxproj...
D:\a\OpenLoco\OpenLoco\src\OpenLoco\openloco.vcxproj : error NU1101: Unable to find package OpenLoco.Dependencies. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages [D:\a\OpenLoco\OpenLoco\openloco.sln]
  Committing restore...
  Generating MSBuild file D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\openloco.vcxproj.nuget.g.props.
  Generating MSBuild file D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\openloco.vcxproj.nuget.g.targets.
  Writing assets file to disk. Path: D:\a\OpenLoco\OpenLoco\src\OpenLoco\obj\project.assets.json
  Failed to restore D:\a\OpenLoco\OpenLoco\src\OpenLoco\openloco.vcxproj (in 942 ms).

Repro steps
Please look at https://github.com/OpenLoco/OpenLoco/actions

@maxim-lobanov
Copy link
Contributor

Hello @AaronVanGeffen , do you have nuget.config file in your repo?
I think it is known issue when you don't have config file.
Could you please try to add simple nuget.config like described in the message: actions/setup-dotnet#155 (comment)

AaronVanGeffen added a commit to AaronVanGeffen/OpenLoco that referenced this issue Mar 27, 2021
@AaronVanGeffen
Copy link
Author

Hello @maxim-lobanov, thank you for the suggestion. Indeed, there was no nuget.config file in our repository. Previously this worked fine, so I was not aware we would need any. However, adding the config file as you suggested appears to have helped: OpenLoco/OpenLoco#855

@maxim-lobanov
Copy link
Contributor

Cool, glad to hear that it helped.

Looks like sometimes dotnet doesn't resolve packages from remote when doesn't find packages in local cache.
I think It is not the new issue since based on actions/setup-dotnet#155 (comment), it fails pretty randomly without nuget.config file.

The root cause is still unclear but using nuget.config is recommendation from NuGet team to deal with this issue: NuGet/Home#10586 (comment)

duncanspumpkin pushed a commit to OpenLoco/OpenLoco that referenced this issue Mar 27, 2021
@AaronVanGeffen
Copy link
Author

Thank you for the explanation. Just to confirm, CI has been working reliably tonight with the nuget.config file in.

@miketimofeev
Copy link
Contributor

@AaronVanGeffen thanks for the confirmation!
I'm going to close the issue but feel free to contact us if you have any concerns.

@rokups
Copy link

rokups commented Apr 2, 2021

I bumped into same issue. While workaround does work i noticed that PATH printed by setup-dotnet action differs on failing and succeeding builds. Failing builds have C:\hostedtoolcache\windows\Java_Adopt_jdk\8.0.282+8\x64\bin in the PATH and succeeding builds have C:\Program Files\Java\jdk8u282-b08\bin. I suspect not all build workers use same image even if all of them use windows-latest.

@miketimofeev
Copy link
Contributor

@rokups it takes 3-4 days to propagate the new image (with Java in the hostedtoolcache directory) to all the environments. We're going to finish the deployment on Monday

@fabriciomurta
Copy link

fabriciomurta commented Apr 5, 2021

Hello, I believe this issue should be better investigated and (hopefully) solved without the need of wrapping our own nuget.config file. The NuGet config should be the same across different instances of Windows runners and I would also expect them to match Mac and Linux (which does not suffer from this problem) runners;

It sounds reasonable to have nuget.org source enabled by default if any packages are not found in local cache (which makes sense for the runtime environments not to keep downloading packages form NuGet.org every run).

Note: I have two different runs in the same 20210330.2 environment version, one failing and another succeeding. It really looks like runners are not being properly cleaned up after a previous run.

@miketimofeev
Copy link
Contributor

@fabriciomurta no, it's not possible — every run is performed on a clean agent

@asklar
Copy link
Contributor

asklar commented Apr 7, 2021

@miketimofeev @maxim-lobanov Can you please reactivate this issue and help us get to a resolution? The core NuGet issue NuGet/Home#10586 was closed without a resolution other than "clean the nuget cache" or "have a nuget.config" which don't seem productive, since restoring projects used to work fine before the last AzDO pipelines/GHA updates.
You're saying it's not possible that this is due to non-clean state on the agent (which I'd agree with), but nuget folks are implying the contrary.

Both this and the NuGet issue are closed and we need someone to step up in either of the teams and provide a solution. We have multiple repos - both internal and external - that got broken since the latest update.

@miketimofeev miketimofeev reopened this Apr 7, 2021
@miketimofeev
Copy link
Contributor

@asklar reopened. Could you please share some repo where the issue persists? We've tried to reproduce last time without any luck

@rokups
Copy link

rokups commented Apr 7, 2021

You may use https://github.com/rokups/rbfx if it is not too fat. Delete nuget.config from root folder to make it fail.

@asklar
Copy link
Contributor

asklar commented Apr 7, 2021

@miketimofeev thanks. We're hitting this in https://github.com/microsoft/react-native-windows/ among others

@dsame dsame assigned dsame and unassigned dsame Apr 7, 2021
nogic1008 added a commit to nogic1008/dotnet-ci-example that referenced this issue Apr 14, 2021
…6.9.* (#55)

* fix(deps): update Microsoft.NET.Test.Sdk requirement

Updates the requirements on [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) to permit the latest version.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Commits](microsoft/vstest@v16.8.0...v16.9.1)

Signed-off-by: dependabot[bot] <support@github.com>

* build: update lock file
* ci: remove workaround for actions/runner-images#3038

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nogic <24802730+nogic1008@users.noreply.github.com>
@miketimofeev
Copy link
Contributor

Hello, everyone!
The new image has been deployed. Please check if you have any issues now.
We're going to close this issue after a few confirmations that everything works fine now.

@miketimofeev
Copy link
Contributor

miketimofeev commented Apr 15, 2021

We've found the root cause of the empty config file and it's related to the chocolatey chocolatey/choco#2233

@anpaz
Copy link

anpaz commented Apr 15, 2021

@miketimefeev, what image version was this fixed on? I just tried on '20210411.1' and I still see the problem.

@asklar
Copy link
Contributor

asklar commented Apr 15, 2021

@miketimofeev thanks a lot for drilling down and finding the issue, much appreciated! This would also explain why some of our customers who use our dependencies script (which uses choco) are hitting this too!

@xt0rted
Copy link

xt0rted commented Apr 15, 2021

We're going to close this issue after a few confirmations that everything works fine now.

I just updated my test PR that was doing Remove-Item $env:APPDATA\NuGet\NuGet.Config and I'm no longer getting the NuGet restore error so it looks to be working now.

My setup is .net sdk 5.0.202, no nuget.config, and setting a GPR feed in the actions/setup-dotnet step. Prior to this update only packages in the GPR feed would restore but now the ones from nuget.org are as well.

@ltrzesniewski
Copy link

I removed a build step which executed the following on 2 of my repos:

dotnet nuget locals all --clear
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org

And the builds run fine now! Thanks!

Additional details:

  • One of the builds uses dotnet restore, the other one uses msbuild /t:Restore
  • I don't have nuget.config files in the repos

@robgilliam
Copy link

@miketimofeev when/where will this be fixed?

This started to be a problem for us on 29th April (4am, UK time) and is still failing today on the 20210425.1 release of windows-latest for any of our Cake-based builds, which are trying (and failing) to restore Cake from NuGet.org:

image

due to the $env:AppData\NuGet\NuGet.Config having no sources specified:

image

(Note: this content is slightly different to the one shown in chocolatey/nuget-chocolatey#23)

This is affecting all our Cake-based actions, only one of which is explicitly using Chocolatey (all are using actions/checkout@v2 and actions/setup-dotnet@v1, if that's significant).

Adding our internal company NuGet server as a source using a run: step that executes before the attempt to download Cake "fixes" (i.e. works around) the problem as it adds the default nuget.org source to the configuration as well as the company server.

@robgilliam
Copy link

I've dug into this a bit more, and in (at least one of) the actions that don't use Chocolatey, the bad NuGet.Config file is created by the following lines in the .yaml file for the action:

  run: |
    Import-Module PowerShellGet
    $env:PSModulePath = "C:\Modules\azurerm_6.13.1;C:\ProgramFiles\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules"
    Install-Module AzureAD -Force
    # Invoke PowerShell script which runs Cake build here.

The last one (Install-Module) is the actual culprit: remove that and the source-less NuGet.Config file isn't created, and the Cake package restore works fine.

@miketimofeev
Copy link
Contributor

@robgilliam chocolatey already fixed the issue on their side, but we have to wait for a new release. Speaking about Powershell module installation — it's a new case we've never seen before. Does any module installation cause the issue or it's AzureAD specific?

@robgilliam
Copy link

robgilliam commented May 11, 2021

@miketimofeev I don't know - all of my "not using Chocolatey" actions that are affected are just using PowerShellGet to install the AzureAD module.

Having identified the extent of the impact on our projects and the easiest work-around (add a nuget sources list step after setup-dotnet runs and before anything else), and spent nearly three days (and one very late night) fixing it, I can't spend more time investigating further. Sorry.

@miketimofeev
Copy link
Contributor

@robburger thanks! I can confirm — the issue is reproducible with any PowerShell module. We will engage the Dotnet team.

@miketimofeev miketimofeev added the awaiting-deployment Code complete; awaiting deployment and/or deployment in progress label May 14, 2021
@miketimofeev
Copy link
Contributor

We've added NuGet.config with nuget.org source in the user's home directory so that neither choco nor PowerShell won't create it using their embedded nuget.
I'm going to close the issue. If anyone sees any other cases please contact us.
Thank you!

@miketimofeev miketimofeev removed the awaiting-deployment Code complete; awaiting deployment and/or deployment in progress label May 21, 2021
martijnvanschie added a commit to martijnvanschie/azure-utilities-eventgrid that referenced this issue Apr 4, 2022
@fsarter
Copy link

fsarter commented Jun 30, 2022

I removed a build step which executed the following on 2 of my repos:

dotnet nuget locals all --clear
dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org

And the builds run fine now! Thanks!

Additional details:

  • One of the builds uses dotnet restore, the other one uses msbuild /t:Restore
  • I don't have nuget.config files in the repos

You saved my life !!! I enounter the same issue after installing Visual Studio 2022 for the first time. I think i should get some details about nuget. Thanks a lot.

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