Skip to content

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

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

Labels

Type

No fields configured for Bug.

Projects

Status
Assigned

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions