Skip to content

bug: npm run lint:ps fails when logs/ directory does not exist #497

@andrewDoing

Description

@andrewDoing

Description

Running npm run lint:ps (or npm run lint:all) in a fresh devcontainer or clone fails with:

Write-Error: PSScriptAnalyzer failed: Could not find a part of the path '/workspaces/hve-core/logs/psscriptanalyzer-results.json'.

Root Cause

Invoke-PSScriptAnalyzer.ps1 writes results to logs/psscriptanalyzer-results.json and logs/psscriptanalyzer-summary.json, but never ensures the logs/ directory exists before writing. The logs/ directory is gitignored, so it is not present after a fresh clone or codespace creation.

Neither the devcontainer lifecycle scripts (on-create.sh, post-create.sh) nor the linting script itself create the directory.

Reproduction

  1. Open hve-core in a fresh codespace or devcontainer
  2. Run npm run lint:ps
  3. Observe the path error

Suggested Fix

Either:

  1. In Invoke-PSScriptAnalyzer.ps1: Add New-Item -ItemType Directory -Force -Path (Split-Path $OutputPath) before writing results (defensive, self-contained fix).
  2. In post-create.sh: Add mkdir -p logs so the directory exists after container setup.
  3. Both: Apply option 1 for robustness and option 2 for consistency.

Workaround

mkdir -p logs

Affected Scripts

Environment

  • DevContainer on Ubuntu 24.04
  • PowerShell 7.5.4
  • Node.js 24.x

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageRequires triage and prioritization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions