Skip to content

HOME_DIRECTORY passes NaN to fs.existsSync on macOS/Linux #247

@taylortom

Description

@taylortom

On macOS and Linux, HOMEDRIVE and HOMEPATH env vars are undefined. The expression process.env.HOMEDRIVE + process.env.HOMEPATH evaluates to NaN (number), which is then passed to fs.existsSync().

Node 24 deprecated non-string arguments to fs.existsSync (DEP0187), and this triggers a deprecation warning which causes node:test to fail an entire AAT test file.

Location: lib/util/constants.js:17

export const HOME_DIRECTORY = [
  process.env.HOME,
  (process.env.HOMEDRIVE + process.env.HOMEPATH), // ← NaN on non-Windows
  process.env.USERPROFILE,
  '/tmp',
  '/temp'
].filter(fs.existsSync)[0]

Suggested fix: Guard the concatenation and filter out non-string values before calling existsSync.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    New

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions