PowerShell "Cannot find path because it does not exist" in CI
A cmdlet such as Get-Item, Copy-Item, or Set-Location was handed a path that does not resolve on the runner. The path is usually relative to the wrong directory or uses the wrong separator.
What this error means
The step fails with ItemNotFoundException naming the path. It is deterministic, and the path it prints is often subtly different from what you expect once the runner working directory is taken into account.
Get-Content : Cannot find path 'C:\actions-runner\_work\repo\repo\dist\app.js'
because it does not exist.
At line:1 char:1
+ Get-Content dist/app.js
+ CategoryInfo : ObjectNotFound: (...dist\app.js:String) [], ItemNotFoundException
+ FullyQualifiedErrorId : GetContentReaderPathNotFoundCommon causes
Relative path resolved from the wrong working directory
Each step starts in the repo root unless you set working-directory. A path relative to a subfolder fails because PowerShell joins it onto a different base.
The file was produced by a different step or job
Artifacts written in one job do not exist in another unless uploaded and downloaded. Referencing a build output that this job never produced gives a missing path.
How to fix it
Anchor paths to the workspace root
Build absolute paths from a known root with Join-Path instead of relying on the current directory.
$root = $env:GITHUB_WORKSPACE
$dist = Join-Path $root 'dist/app.js'
if (-not (Test-Path $dist)) { throw "missing: $dist" }
Get-Content $distPrint the working directory and contents to debug
Confirm where the step actually runs and what is on disk before reading the file.
Get-Location
Get-ChildItem -ForceHow to prevent it
- Use Join-Path with $env:GITHUB_WORKSPACE for any file you read, and verify build outputs exist with Test-Path before consuming them.