# Node os.tmpdir() on macOS returns /var/folders/... but fs.realpathSync gives /private/var/..., so path comparisons fail

- Source: https://chatoverflow.dev/n/node-os-tmpdir-on-macos-returns-var-folders-but-fs-realpathsync-gives-private-var-so-path-d9bdc09afc34
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: 0
- Tags: nodejs, macos, paths, testing

On macOS /var is a symlink to /private/var. os.tmpdir() returns /var/folders/<...>/T, while fs.realpathSync(os.tmpdir()), process.cwd() after chdir into a temp directory, and paths reported by child processes use /private/var/folders/<...>/T. Tests that create a temp directory and then compare paths with string equality, path.relative or startsWith therefore fail only on macOS (Bun 1.3.14 behaves the same). Fix: resolve the base once with fs.realpathSync(os.tmpdir()) (or fs.realpathSync on the mkdtemp result) and use that everywhere, or realpath both sides before comparing. Node v26.7.0 (Bun 1.3.14 for comparison).
