flutter-action icon indicating copy to clipboard operation
flutter-action copied to clipboard

Action fails on Windows runners without admin rights

Open brookman opened this issue 8 months ago • 3 comments

Version v2.19.0 fails on Windows runners during choco install yq. I have no admin rights on the runners and I don't use the "flutter-version-file" feature. However it seems flutter-action still tries to install yq. Logs:

Run choco install yq
Chocolatey v2.3.0
Chocolatey detected you are not running from an elevated command shell
 (cmd/powershell).

 You may experience errors - many functions/packages
 require admin rights. Only advanced users should run choco w/out an
 elevated shell. When you open the command shell, you should ensure
 that you do so with "Run as Administrator" selected. If you are
 attempting to use Chocolatey in a non-administrator setting, you
 must select a different location other than the default install
 location. See
 https://docs.chocolatey.org/en-us/choco/setup#non-administrative-install
 for details.


 Do you want to continue?([Y]es/[N]o): 
Timeout or your choice of '' is not a valid selection.
Installing the following packages:
yq
By installing, you accept licenses for the packages.
Downloading package from source 'https://community.chocolatey.org/api/v2/'

Progress: Downloading yq 4.45.1... 27%
Progress: Downloading yq 4.45.1... 83%
Progress: Downloading yq 4.45.1... 100%
yq not installed. An error occurred during installation:
 Unable to obtain lock file access on 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' for operations on 'C:\ProgramData\chocolatey\lib\yq'. This may mean that a different user or administrator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' will allow NuGet to continue.
yq package files install failed with exit code 1. Performing other installation steps.
The install of yq was NOT successful.
yq not installed. An error occurred during installation:
 Unable to obtain lock file access on 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' for operations on 'C:\ProgramData\chocolatey\lib\yq'. This may mean that a different user or administrator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' will allow NuGet to continue.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
Maximum tries of 3 reached. Throwing error.
Cannot create directory "C:\ProgramData\chocolatey\lib-bad". Error was:
System.UnauthorizedAccessException: Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.Directory.InternalCreateDirectory(String fullPath, String path, Object dirSecurityObj, Boolean checkHost)
   at System.IO.Directory.InternalCreateDirectoryHelper(String path, Boolean checkHost)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.<>c__DisplayClass63_0.<CreateDirectory>b__1()
   at chocolatey.infrastructure.tolerance.FaultTolerance.<>c__DisplayClass1_0.<Retry>b__0()
   at chocolatey.infrastructure.tolerance.FaultTolerance.Retry[T](Int32 numberOfTries, Func`1 function, Int32 waitDurationMilliseconds, Int32 increaseRetryByMilliseconds, Boolean isSilent)
   at chocolatey.infrastructure.tolerance.FaultTolerance.Retry(Int32 numberOfTries, Action action, Int32 waitDurationMilliseconds, Int32 increaseRetryByMilliseconds, Boolean isSilent)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.CreateDirectory(String directoryPath, Boolean isSilent)
   at chocolatey.infrastructure.filesystem.DotNetFileSystem.EnsureDirectoryExists(String directoryPath, Boolean ignoreError, Boolean isSilent)

Chocolatey installed 0/0 packages. 
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
Access to the path 'C:\ProgramData\chocolatey\lib-bad' is denied.
Error: Process completed with exit code 1.

brookman avatar Apr 01 '25 05:04 brookman

I dont think this is flutter related, it sounds like an issue with chocolatey, not with flutter itself as flutter is not an package manager, so it is not the fault of flutter-action. After looking at the logs you provided, it looks like it's a permission and file lock issue, so you need to make sure Chocolatey can access the lock file. It even tells you exactly what’s wrong here and how to fix it:

Unable to obtain lock file access on 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' for operations on 'C:\ProgramData\chocolatey\lib\yq'. This may mean that a different user or administrator is holding this lock and that this process does not have permission to access it. If no other process is currently performing an operation on this file it may mean that an earlier NuGet process crashed and left an inaccessible lock file, in this case removing the file 'C:\ProgramData\chocolatey\lib\c0c62c52c06b8c640f328d2653270d84385bcf38' will allow NuGet to continue.

That said, these days Windows has its own package manager called winget, so I’m not really sure why you're still using Chocolatey in the first place. Personally, when I tried out Chocolatey years ago, I ran into similar issues with permissions and broken files and the like. Switching to winget has been much smoother experience for me. With winget, you can just do: winget install yq -e

Good luck :)

SrS2225a avatar May 28 '25 15:05 SrS2225a

Wait a sec, sorry about that, disregard. I misread that, I read it as you were trying to install yq with Chocolatey additionally, and not from flutter-action. Sorry for the confusion. But maybe you can use my comments to find an solution? 🤷. You can probably just change the projects main/action.yaml to call for winget instead

SrS2225a avatar May 28 '25 15:05 SrS2225a

Not sure if you are an LLM or a human. Anyway, if you check line 88 you can see that this action is calling choco install yq. I can‘t control that from my code. The issue is that this fails on my CI runner (due to missing admin rights) and yq is not even needed in my case because I don‘t use the feature „ flutter-version-file“.

brookman avatar May 28 '25 18:05 brookman

@brookman does https://github.com/subosito/flutter-action/pull/362 being merged fix this?

beninato8 avatar Jun 17 '25 17:06 beninato8

I can’t test it because I‘m no longer working on that project. But it looks like the PR indeed fixes the issue. Thanks! 👍

brookman avatar Jun 17 '25 21:06 brookman