arcade icon indicating copy to clipboard operation
arcade copied to clipboard

Set DOTNET_CLI_HOME to a repo-local path

Open dsplaisted opened this issue 5 years ago • 17 comments

  • [ ] This issue is blocking
  • [ ] This issue is causing unreasonable pain

By default, the CLI will use a user-specific folder for a few things, including first run sentinels and global tool information. The folder can be overridden with the DOTNET_CLI_HOME environment variable. Arcade should set this variable to a repo-local path, to avoid different builds (ie on CI machines or build servers) sharing this folder. While we should generally keep compatibility, that may not always be true between interim preview builds.

This has broken builds at least twice:

  • https://github.com/dotnet/sdk/issues/10938#issuecomment-601997145
  • https://github.com/dotnet/aspnetcore/pull/21017#issuecomment-623261256

dsplaisted avatar May 04 '20 16:05 dsplaisted

@janvorli that's the issue that is tracking the right fix for the issue that you were seeing locally. cc @jaredpar

ViktorHofer avatar May 04 '20 18:05 ViktorHofer

Running this test build where I set the variable to the build workspace directory: https://dev.azure.com/dnceng/internal/_build/results?buildId=724637&view=results

riarenas avatar Jul 10 '20 16:07 riarenas

Ahh, forgot that arcade doesn't have a linux build leg. Will test this in arcade-validation instead.

riarenas avatar Jul 10 '20 16:07 riarenas

PR to set this during CI: https://github.com/dotnet/arcade/pull/5775

riarenas avatar Jul 13 '20 14:07 riarenas

My fix doesn't work for docker containers that are started during the build, as oposed as having the entire leg running inside a container. Reopening.

https://dev.azure.com/dnceng/internal/_build/results?buildId=735034&view=logs&j=b72e85ab-3386-5aa9-6405-3837662d9688&t=f60252b2-6cdd-5047-3d04-b33edb9d8faa

riarenas avatar Jul 17 '20 13:07 riarenas

Made a better fix, which sets the variable to the root of the repo during CI in #5805

riarenas avatar Jul 17 '20 16:07 riarenas

Reopening and putting in the backlog. This change was the source for https://github.com/dotnet/arcade/issues/5813 , but since it has the context I'm reactivating this one.

The latest arcade validation builds were failing to resolve nuget v3 paths, reverting just this change unblocked them, as shown in this build

MattGal avatar Jul 20 '20 18:07 MattGal

I believe the change is still the correct change, and whoever picks this up next can investigate why this fails runtime's build. My guess is that Runtime is doing something weird and they should react to the change, rather than not making it.

riarenas avatar Jul 22 '20 16:07 riarenas

Okay I figured out why this change broke runtime. The build uses a NuGetAuthenticate task (https://github.com/microsoft/azure-pipelines-tasks/blob/d925deb300d85a09f8ed2d5d8a16f74cdb6fa8c5/Tasks/NuGetAuthenticateV0/main.ts#L16) to authenticate to private azure feeds.

That task installs the credential provider into the $HOME directory, if we then set DOTNET_CLI_HOME to something else, that credential provider is lost and the restore can't use private feeds.

I think we just.... can't set DOTNET_CLI_HOME, unless we want to copy the plugins from $HOME into the new location at the same time.

alexperovich avatar Jul 29 '20 23:07 alexperovich

Thanks @alexperovich . I think at this point let's drop it out of FR (remove epic and labels) so we can make sure there's consensus on "won't fix-ing" tomorrow at triage?

MattGal avatar Jul 29 '20 23:07 MattGal

Yea, thats probably good.

alexperovich avatar Jul 30 '20 00:07 alexperovich

Great finding, thanks Alex. Should we fix https://github.com/microsoft/azure-pipelines-tasks/blob/69bdf79bd5d624cf5f8733cd25636df5008f7cf2/Tasks/Common/artifacts-common/credentialProviderUtils.ts#L96 to respect the environment variable and not blindly read from the hardcoded location? cc @nkolev92

ViktorHofer avatar Jul 30 '20 16:07 ViktorHofer

Making that task respect the environment variable is probably good, but it wouldn't fix it in this case because the variable isn't until tools.ps1 is called. We would need to set that variable in the build earlier than the restore task.

-------- Original message -------- From: Viktor Hofer [email protected] Date: 7/30/20 9:31 AM (GMT-08:00) To: dotnet/arcade [email protected] Cc: Alex Perovich [email protected], Mention [email protected] Subject: Re: [dotnet/arcade] Set DOTNET_CLI_HOME to a repo-local path (#5402)

Great finding, thanks Alex. Should we fix https://github.com/microsoft/azure-pipelines-tasks/blob/69bdf79bd5d624cf5f8733cd25636df5008f7cf2/Tasks/Common/artifacts-common/credentialProviderUtils.ts#L96https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fazure-pipelines-tasks%2Fblob%2F69bdf79bd5d624cf5f8733cd25636df5008f7cf2%2FTasks%2FCommon%2Fartifacts-common%2FcredentialProviderUtils.ts%23L96&data=02%7C01%7CAlex.Perovich%40microsoft.com%7C5814eb3aa50e49a13aa108d834a60411%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637317234925248414&sdata=onuUCV%2FzcKv5Htbs4vYJ1aRI3fsWmpWfDGpgt%2F9OpRI%3D&reserved=0 to respect the environment variable and not blindly read from the hardcoded location? cc @nkolev92https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnkolev92&data=02%7C01%7CAlex.Perovich%40microsoft.com%7C5814eb3aa50e49a13aa108d834a60411%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637317234925258406&sdata=vD8zW47%2BSr9lOOSSYMCfYsDbH6srM5xeScMnEhgp8Hs%3D&reserved=0

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdotnet%2Farcade%2Fissues%2F5402%23issuecomment-666508927&data=02%7C01%7CAlex.Perovich%40microsoft.com%7C5814eb3aa50e49a13aa108d834a60411%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637317234925268405&sdata=QK1xFd8Zxa75TDfNV1MEmZ3sISyXFdCy3jQO82bV%2Fvc%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FACQTOIWN72QFLKNM5ZM5HADR6GN6FANCNFSM4MY4TDBQ&data=02%7C01%7CAlex.Perovich%40microsoft.com%7C5814eb3aa50e49a13aa108d834a60411%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637317234925268405&sdata=TK97TnnMsFeWQ%2BB0TVMyUMKWsqgacSl6uWr2rSKu4Bk%3D&reserved=0.

alexperovich avatar Jul 30 '20 16:07 alexperovich

Filed issue with azure pipelines: https://github.com/microsoft/azure-pipelines-tasks/issues/13375

alexperovich avatar Jul 30 '20 20:07 alexperovich

Triage: For Helix, a Big Improvement would be to recycle machines for every build (hosted pool does this).

garath avatar Jul 30 '20 20:07 garath

I'm all for better isolation between CI builds – it really makes everything so much simpler – but https://github.com/dotnet/runtime/issues/34994 is a local build problem and is waiting for the resolution of this issue.

lukas-lansky avatar Feb 09 '21 10:02 lukas-lansky

This issue points to a local build problem, you are right. But we would still see the issue if we wouldn't have disable repo tools being restored in CI temporarily: https://github.com/dotnet/runtime/commit/97d1f9698cfa20054a2909ad2e4e9c4ee20a7520. So this still very much applies and needs to be fixed.

ViktorHofer avatar Feb 09 '21 11:02 ViktorHofer