fix(cli): use os.homedir() for home directory warning check (#25890)

This commit is contained in:
Tirth Naik
2026-05-04 16:24:49 -07:00
committed by GitHub
parent 04e875c5c8
commit 8f0edcd64f
2 changed files with 54 additions and 6 deletions
@@ -5,10 +5,10 @@
*/
import fs from 'node:fs/promises';
import { homedir as osHomedir } from 'node:os';
import path from 'node:path';
import process from 'node:process';
import {
homedir,
getCompatibilityWarnings,
WarningPriority,
type StartupWarning,
@@ -39,10 +39,10 @@ const homeDirectoryCheck: WarningCheck = {
try {
const [workspaceRealPath, homeRealPath] = await Promise.all([
fs.realpath(workspaceRoot),
fs.realpath(homedir()),
fs.realpath(osHomedir()),
]);
if (workspaceRealPath === homeRealPath) {
if (path.resolve(workspaceRealPath) === path.resolve(homeRealPath)) {
// If folder trust is enabled and the user trusts the home directory, don't show the warning.
if (
isFolderTrustEnabled(settings) &&