janhq/jan · error · Error

Invalid path or file ${path}

Error message

Invalid path or file ${path}

What it means

Input validation at the start of the install-from-archive method: the path must exist on disk AND end in either '.tar.gz' or '.zip'. If either condition fails, the method throws before attempting any decompression or parsing.

Source

Thrown at extensions/llamacpp-extension/src/index.ts:2859

    // Match prefix (optional), llama, main (optional), version (b####-hash),
    // optional cudart-llama, bin, backend details
    // Examples:
    // - k_llama-main-b4314-09c61e1-bin-win-cuda-12.8-x64-avx2.zip
    // - ik_llama-main-b4314-09c61e1-cudart-llama-bin-win-cuda-12.8-x64-avx512.zip
    // - llama-b7037-bin-win-cuda-12.4-x64.zip (legacy format)
    const re =
      /^(.+?[-_])?llama(?:-main)?-(b\d+(?:-[a-f0-9]+)?)(?:-cudart-llama)?-bin-(.+?)\.(?:tar\.gz|zip)$/

    const archiveName = await basename(path)
    logger.info(`Installing backend from path: ${path}`)

    if (
      !(await fs.existsSync(path)) ||
      (!path.endsWith('tar.gz') && !path.endsWith('zip'))
    ) {
      logger.error(`Invalid path or file ${path}`)
      throw new Error(`Invalid path or file ${path}`)
    }

    const match = re.exec(archiveName)

    if (!match) {
      throw new Error(
        `Failed to parse archive name: ${archiveName}. Expected format: [Optional prefix-]llama-<version>-bin-<backend>.(tar.gz|zip)`
      )
    }

    const [, prefix, version, backend] = match

    if (!version || !backend) {
      throw new Error(`Invalid backend archive name: ${archiveName}`)
    }

    // Include prefix in the backend identifier if present
    const backendIdentifier = prefix ? `${prefix}${backend}` : backend

View on GitHub (pinned to fad3f12a14)

Solutions

  1. Ensure the archive is a .tar.gz (Linux/macOS) or .zip (Windows) file matching the expected naming convention.
  2. Verify the file exists at the given path before invoking the install method.
  3. If you have a different archive format, re-package or re-download in a supported format.
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'node:fs'

function isValidArchivePath(path: string): boolean {
  return fs.existsSync(path) && (path.endsWith('.tar.gz') || path.endsWith('.zip'))
}

// Before calling install:
if (!isValidArchivePath(path)) {
  throw new Error(`Path must be an existing .tar.gz or .zip file: ${path}`)
}

Type guard

function isSupportedArchivePath(path: string): boolean {
  return path.endsWith('.tar.gz') || path.endsWith('.zip')
}

Prevention

When it happens

Trigger: The user-supplied path points to a non-existent file; the file exists but has a different extension (.7z, .tar.xz, .exe, no extension); the path has a typo; the file was deleted between selection and installation.

Common situations: User selects a .7z or .tar.xz archive that the extension does not support; file picker was pointed at a directory instead of an archive; a download was interrupted and the partial file has a .tmp extension.

Related errors


AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12). Data as JSON: /api/errors/44e25a257921d3ba. Report an issue: GitHub.