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

self-hosted Windows runners fail with Remove-Item : Cannot find path #1985

Open
ssbarnea opened this issue Nov 20, 2024 · 5 comments
Open

self-hosted Windows runners fail with Remove-Item : Cannot find path #1985

ssbarnea opened this issue Nov 20, 2024 · 5 comments

Comments

@ssbarnea
Copy link

ssbarnea commented Nov 20, 2024

It seems that the checkout action fails to checkout with a cryptic error on self-hosted runners. Error looks like below:

2024-11-20T12:35:36.9368944Z Current runner version: '2.320.0'
2024-11-20T12:35:36.9377135Z Runner name: 'BMW10'
2024-11-20T12:35:36.9377659Z Runner group name: 'Default'
2024-11-20T12:35:36.9378345Z Machine name: 'BMW10'
2024-11-20T12:35:36.9398704Z Testing runner upgrade compatibility
2024-11-20T12:35:37.0512971Z ##[group]GITHUB_TOKEN Permissions
2024-11-20T12:35:37.0515288Z Actions: write
2024-11-20T12:35:37.0515773Z Attestations: write
2024-11-20T12:35:37.0516307Z Checks: write
2024-11-20T12:35:37.0516703Z Contents: write
2024-11-20T12:35:37.0517128Z Deployments: write
2024-11-20T12:35:37.0517612Z Discussions: write
2024-11-20T12:35:37.0518019Z Issues: write
2024-11-20T12:35:37.0518415Z Metadata: read
2024-11-20T12:35:37.0518876Z Packages: write
2024-11-20T12:35:37.0519273Z Pages: write
2024-11-20T12:35:37.0519682Z PullRequests: write
2024-11-20T12:35:37.0520133Z RepositoryProjects: write
2024-11-20T12:35:37.0520647Z SecurityEvents: write
2024-11-20T12:35:37.0521126Z Statuses: write
2024-11-20T12:35:37.0521787Z ##[endgroup]
2024-11-20T12:35:37.0524365Z Secret source: Actions
2024-11-20T12:35:37.0525104Z Prepare workflow directory
2024-11-20T12:35:37.2774654Z Prepare all required actions
2024-11-20T12:35:37.2982124Z Getting action download info
2024-11-20T12:35:37.7021673Z Download action repository 'actions/checkout@v4' (SHA:11bd71901bbe5b1630ceea73d27597364c9af683)
2024-11-20T12:35:38.7494630Z Download action repository 'Vampire/setup-wsl@v3.1.3' (SHA:23f94bc31caaddc08bd1230a00b89f872633d8d7)
2024-11-20T12:35:42.4253497Z Download action repository 'asdf-vm/actions@v3' (SHA:05e0d2ed97b598bfce82fd30daf324ae0c4570e6)
2024-11-20T12:35:43.1729477Z Download action repository 'actions/setup-python@v5' (SHA:0b93645e9fea7318ecaed2b359559ac225c90a2b)
2024-11-20T12:35:46.3496008Z Download action repository 'actions/cache@v4' (SHA:6849a6489940f00c2f30c0fb92c6274307ccb58a)
2024-11-20T12:35:50.9379441Z Download action repository 'actions/upload-artifact@v4' (SHA:b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882)
2024-11-20T12:35:52.7592861Z Complete job name: test (wsl)
2024-11-20T12:35:52.9205911Z ##[group]Run actions/checkout@v4
2024-11-20T12:35:52.9206956Z with:
2024-11-20T12:35:52.9207286Z   fetch-depth: 0
2024-11-20T12:35:52.9207688Z   show-progress: false
2024-11-20T12:35:52.9208190Z   repository: ansible/vscode-ansible
2024-11-20T12:35:52.9209119Z   token: ***
2024-11-20T12:35:52.9209478Z   ssh-strict: true
2024-11-20T12:35:52.9209857Z   ssh-user: git
2024-11-20T12:35:52.9210256Z   persist-credentials: true
2024-11-20T12:35:52.9210740Z   clean: true
2024-11-20T12:35:52.9211144Z   sparse-checkout-cone-mode: true
2024-11-20T12:35:52.9211713Z   fetch-tags: false
2024-11-20T12:35:52.9212089Z   lfs: false
2024-11-20T12:35:52.9212435Z   submodules: false
2024-11-20T12:35:52.9212857Z   set-safe-directory: true
2024-11-20T12:35:52.9213309Z env:
2024-11-20T12:35:52.9213814Z   FORCE_COLOR: 1
2024-11-20T12:35:52.9214615Z   PRETTIER_LEGACY_CLI: 1
2024-11-20T12:35:52.9216928Z   WSLENV: HOSTNAME:CI:FORCE_COLOR:GITHUB_ACTION:GITHUB_ACTION_PATH/p:GITHUB_ACTION_REPOSITORY:GITHUB_WORKFLOW:GITHUB_WORKSPACE/p:GITHUB_PATH/p:GITHUB_ENV/p:VIRTUAL_ENV/p:SKIP_PODMAN:SKIP_DOCKER
2024-11-20T12:35:52.9219318Z   HOSTNAME: gha
2024-11-20T12:35:52.9219688Z   SKIP_DOCKER: 1
2024-11-20T12:35:52.9220058Z   SKIP_PODMAN: 1
2024-11-20T12:35:52.9221187Z   TASKFILE_ARGS: --output=group --output-group-begin='::group::{{.TASK}}' --output-group-end='::endgroup::'
2024-11-20T12:35:52.9222555Z ##[endgroup]
2024-11-20T12:35:53.4244178Z Syncing repository: ansible/vscode-ansible
2024-11-20T12:35:53.4248827Z ##[group]Getting Git version info
2024-11-20T12:35:53.4251344Z Working directory is 'C:\actions-runner\_work\vscode-ansible\vscode-ansible'
2024-11-20T12:35:53.4254379Z ##[endgroup]
2024-11-20T12:35:53.4256238Z Deleting the contents of 'C:\actions-runner\_work\vscode-ansible\vscode-ansible'
2024-11-20T12:35:53.4258692Z The repository will be downloaded using the GitHub REST API
2024-11-20T12:35:53.4259859Z To create a local Git repository instead, add Git 2.18 or higher to the PATH
2024-11-20T12:35:53.4265948Z Downloading the archive
2024-11-20T12:36:01.0623502Z Writing archive to disk
2024-11-20T12:36:01.0902602Z Extracting the archive
2024-11-20T12:36:01.1161324Z [command]C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoLogo -Sta -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command "$ErrorActionPreference = 'Stop' ; try { Add-Type -AssemblyName System.IO.Compression.FileSystem } catch { } ; if ((Get-Command -Name Expand-Archive -Module Microsoft.PowerShell.Archive -ErrorAction Ignore)) { Expand-Archive -LiteralPath 'C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a73c8.zip' -DestinationPath 'C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a73c8' -Force } else {[System.IO.Compression.ZipFile]::ExtractToDirectory('C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a73c8.zip', 'C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a73c8', $true) }"
2024-11-20T12:36:10.9269818Z Remove-Item : Cannot find path 'C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a7
2024-11-20T12:36:10.9273547Z 3c8\ansible-vscode-ansible-53c17d4\.c8rc' because it does not exist.
2024-11-20T12:36:10.9275154Z At 
2024-11-20T12:36:10.9277053Z C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Archive\Microsoft.PowerShell.Archive.psm1:411 
2024-11-20T12:36:10.9278712Z char:46
2024-11-20T12:36:10.9279459Z + ...                 $expandedItems | % { Remove-Item $_ -Force -Recurse }
2024-11-20T12:36:10.9280387Z +                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2024-11-20T12:36:10.9282074Z     + CategoryInfo          : ObjectNotFound: (C:\actions-runn...e-53c17d4\.c8rc:String) [Remove-Item], ItemNotFoundEx 
2024-11-20T12:36:10.9283446Z    ception
2024-11-20T12:36:10.9284416Z     + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
2024-11-20T12:36:10.9287962Z  
2024-11-20T12:36:10.9867878Z ##[error]The process 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe' failed with exit code 1
2024-11-20T12:36:11.0764571Z ##[group]Run actions/upload-artifact@v4

This is a fresh Windows 10 PRO x64 installation with the runner configured to run as a service.

Execution https://github.com/ansible/vscode-ansible/actions/runs/11933502609/job/33260689830?pr=1664

Current runner version: '2.320.0'

One interesting message that I seen before the failure was To create a local Git repository instead, add Git 2.18 or higher to the PATH -- which is unexpected because it was still there even after I manually installed git and checked that git was in PATH.

I was able to reproduce the error when running in local console and I observed that C:\actions-runner\_work\vscode-ansible\vscode-ansible\4eb22f6a-3455-4306-b3b2-63ee299a73c8 folder exists but it is empty.

@ssbarnea
Copy link
Author

ssbarnea commented Nov 20, 2024

I tried to use explorer to unarchive the zip and while it did unarchive most files, it failed with "Destination Path Too Long".

What is worse here is that I installed the runner in the root of the main partition, the default location recommended by the docs. The are barely any options to reduce the path length.

I applied the long path enablement documented on https://learn.microsoft.com/en-us/windows/win32/fileio/maximum-file-path-limitation?tabs=powershell and restarted the system in order to ensure that all processed benefit from it. Tested again with explorer and it was still unable to archive the zip file.

Still, unarchiving the zip to C:\1\ folder succeeded. Still, that is not an option as we have no control on how github runners are using temp folders.

The fact that other Windows runners can clone this repository makes me wonder why it can work on some Windows machine an not others.

@ssbarnea
Copy link
Author

Duplicate of #955 ?

@ssbarnea
Copy link
Author

Apparently this is caused by the unsolved bug from PowerShell/Microsoft.PowerShell.Archive#69 and the workaround is to upgrade powershell archive via:

Install-Module -Name Microsoft.PowerShell.Archive -MinimumVersion 1.2.5 -Scope AllUsers -SkipPublisherCheck

@lucasandre22
Copy link

Hello @ssbarnea, thanks for the possible solution. I tried in my self-hosted windows runner but it still did not work, even though the version of PowerShell.Archive is 1.2.5.
Did you manage to fix with the solution you provided?

@l-fronczyk
Copy link

Make the output directory absolute and prefix it with \\?\ (for example, `\?\c:\temp') to make it UNC compatible. This turns on LFN support.
It has nothing to do with git.

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

No branches or pull requests

3 participants