quasarframework/quasar · error · Error

Could not resolve an existing ancestor for "${target}"

Error message

Could not resolve an existing ancestor for "${target}"

What it means

getExistingAncestor walks up from a target path directory by directory until it finds one that exists, so the build-artifact cleaner has an existing anchor to resolve against. It throws when it reaches the filesystem root (dirname(current) === current) without finding any existing ancestor, meaning the whole chain from target to root is missing or unreadable.

Source

Thrown at app-vite/lib/utils/remove-build-artifacts.js:34

}

function getExistingAncestor(target) {
  let current = target

  while (true) {
    try {
      fse.lstatSync(current)
      return current
    } catch (err) {
      if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') {
        throw err
      }
    }

    const parent = dirname(current)

    if (parent === current) {
      throw new Error(`Could not resolve an existing ancestor for "${target}"`)
    }

    current = parent
  }
}

function getEffectivePath(target) {
  const existingAncestor = getExistingAncestor(target)
  const realAncestor = fse.realpathSync(existingAncestor)

  return resolve(realAncestor, relative(existingAncestor, target))
}

function isFilesystemRoot(target) {
  return target === parse(target).root
}

export function getBuildArtifactsCleanTarget({

View on GitHub (pinned to 4841521b5f)

Solutions

  1. Verify the target path is spelled correctly and at least one ancestor (e.g. the drive root or project dir) exists
  2. Mount the volume or wait for the mount before running the clean step
  3. Recreate the missing parent directory with 'mkdir -p' before invoking the cleaner
  4. Ensure you are passing an absolute path; relative paths resolved from an unexpected cwd may not exist

Example fix

// before
await removeBuildArtifacts({ projectDir: '/mnt/unmounted-vol/app', targetDir: 'dist' })
// after
// mount the volume first, or:
await removeBuildArtifacts({ projectDir: '/home/me/app', targetDir: 'dist' })
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('node:fs')
function hasExistingAncestor(p) {
  let cur = require('node:path').resolve(p)
  while (true) {
    if (fs.existsSync(cur)) return true
    const parent = require('node:path').dirname(cur)
    if (parent === cur) return false
    cur = parent
  }
}
if (!hasExistingAncestor(target)) throw new Error(`No existing ancestor for ${target}`)

Try / catch

try {
  await removeBuildArtifacts(opts)
} catch (err) {
  if (String(err.message).startsWith('Could not resolve an existing ancestor')) {
    // verify path spelling / mount the volume before retrying
  } else throw err
}

Prevention

When it happens

Trigger: Calling removeBuildArtifacts (via existingAncestor) with a target/project path whose every ancestor, up to and including the filesystem root, does not exist or cannot be stat'ed — e.g. a deeply nested path on an unmounted volume or a misspelled absolute path with no existing parents.

Common situations: Typo in an absolute path like /home/user/prokect/dist where nothing exists; deleted or unmounted drive/network mount; container volume not yet mounted when the clean step runs.

Related errors


AI-assisted analysis of quasarframework/quasar@4841521b5f (2026-08-30). Data as JSON: /api/errors/e7af6a8b41565b9d. Report an issue: GitHub.