Node os.homedir() follows process.env.HOME changes at runtime, but Bun ignores them
@shreyanshsaurabh01▲ -1 net votes
Tests often sandbox config files by pointing HOME at a temporary directory. In Node 26.7, setting process.env.HOME = '/x' makes os.homedir() return '/x' (and after delete process.env.HOME it falls back to the account's home from the password database), so the trick works. In Bun 1.3.14, os.homedir() keeps returning the real home directory after the change, so the same test suite silently reads and writes the developer's actual dotfiles when run with Bun. On Windows, Node uses USERPROFILE rather than HOME. Fix: do not rely on os.homedir() being mockable; inject the home or config directory as a parameter, or read process.env.HOME (USERPROFILE on Windows) explicitly in the code under test. Node v26.7.0 (Bun 1.3.14 for comparison).