Skip to content

Misleading error message when Servy CLI is not found #50

@Christophe-Rogiers

Description

@Christophe-Rogiers

Bug Description

When the Servy CLI executable (servy-cli.exe) is not found through any of the three discovery steps in Servy.psm1, the error message in Test-ServyCliPath can be misleading.

Steps to Reproduce

  1. Use the PowerShell module on a system where Servy is not installed
  2. Place the module in a folder that does not contain servy-cli.exe
  3. Call any Servy function (e.g. Show-ServyVersion)

Expected Behavior

The error message should clearly indicate that servy-cli.exe was not found in any of the searched locations (module folder, Program Files, system PATH).

Actual Behavior

The module initialization tries three paths in sequence:

# 1. Check local module folder
$script:ServyCliPath = Join-Path $ModuleRoot "servy-cli.exe"

# 2. Check 64-bit Program Files directory
if (-not (Test-Path $script:ServyCliPath)) {
    $basePath = if ($env:ProgramW6432) { $env:ProgramW6432 } else { $env:ProgramFiles }
    $script:ServyCliPath = Join-Path $basePath "Servy\servy-cli.exe"
}

# 3. Check system PATH
if (-not (Test-Path $script:ServyCliPath)) {
    $pathSearch = Get-Command "servy-cli.exe" -ErrorAction SilentlyContinue
    if ($pathSearch) { $script:ServyCliPath = $pathSearch.Definition }
}

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions