diff --git a/packages/cli/src/utils/userStartupWarnings.test.ts b/packages/cli/src/utils/userStartupWarnings.test.ts index eb892e68cb7..407226cb015 100644 --- a/packages/cli/src/utils/userStartupWarnings.test.ts +++ b/packages/cli/src/utils/userStartupWarnings.test.ts @@ -4,24 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest'; +import { describe, it, expect, beforeEach, afterEach } from 'vitest'; import { getUserStartupWarnings } from './userStartupWarnings.js'; import * as os from 'node:os'; import fs from 'node:fs/promises'; import path from 'node:path'; -// Mock os.homedir to control the home directory in tests -vi.mock('os', async (importOriginal) => { - const actualOs = await importOriginal(); - return { - ...actualOs, - homedir: vi.fn(), - }; -}); - describe('getUserStartupWarnings', () => { let testRootDir: string; - let homeDir: string; let startupOptions: { workspaceRoot: string; useRipgrep: boolean; @@ -30,9 +20,6 @@ describe('getUserStartupWarnings', () => { beforeEach(async () => { testRootDir = await fs.mkdtemp(path.join(os.tmpdir(), 'warnings-test-')); - homeDir = path.join(testRootDir, 'home'); - await fs.mkdir(homeDir, { recursive: true }); - vi.mocked(os.homedir).mockReturnValue(homeDir); startupOptions = { workspaceRoot: testRootDir, useRipgrep: true, @@ -42,31 +29,6 @@ describe('getUserStartupWarnings', () => { afterEach(async () => { await fs.rm(testRootDir, { recursive: true, force: true }); - vi.clearAllMocks(); - }); - - describe('home directory check', () => { - it('should return a warning when running in home directory', async () => { - const warnings = await getUserStartupWarnings({ - ...startupOptions, - workspaceRoot: homeDir, - }); - expect(warnings).toContainEqual( - expect.stringContaining('home directory'), - ); - }); - - it('should not return a warning when running in a project directory', async () => { - const projectDir = path.join(testRootDir, 'project'); - await fs.mkdir(projectDir); - const warnings = await getUserStartupWarnings({ - ...startupOptions, - workspaceRoot: projectDir, - }); - expect(warnings).not.toContainEqual( - expect.stringContaining('home directory'), - ); - }); }); describe('root directory check', () => { @@ -106,7 +68,7 @@ describe('getUserStartupWarnings', () => { }); const expectedWarning = 'Could not verify the current directory due to a file system error.'; - expect(warnings).toEqual([expectedWarning, expectedWarning]); + expect(warnings).toEqual([expectedWarning]); }); }); }); diff --git a/packages/cli/src/utils/userStartupWarnings.ts b/packages/cli/src/utils/userStartupWarnings.ts index e2e7c440c18..ca0d91656b5 100644 --- a/packages/cli/src/utils/userStartupWarnings.ts +++ b/packages/cli/src/utils/userStartupWarnings.ts @@ -5,7 +5,6 @@ */ import fs from 'node:fs/promises'; -import * as os from 'node:os'; import path from 'node:path'; import { canUseRipgrep } from '@qwen-code/qwen-code-core'; @@ -21,25 +20,6 @@ type WarningCheck = { }; // Individual warning checks -const homeDirectoryCheck: WarningCheck = { - id: 'home-directory', - check: async (options: WarningCheckOptions) => { - try { - const [workspaceRealPath, homeRealPath] = await Promise.all([ - fs.realpath(options.workspaceRoot), - fs.realpath(os.homedir()), - ]); - - if (workspaceRealPath === homeRealPath) { - return 'You are running Qwen Code in your home directory. It is recommended to run in a project-specific directory.'; - } - return null; - } catch (_err: unknown) { - return 'Could not verify the current directory due to a file system error.'; - } - }, -}; - const rootDirectoryCheck: WarningCheck = { id: 'root-directory', check: async (options: WarningCheckOptions) => { @@ -81,7 +61,6 @@ const ripgrepAvailabilityCheck: WarningCheck = { // All warning checks const WARNING_CHECKS: readonly WarningCheck[] = [ - homeDirectoryCheck, rootDirectoryCheck, ripgrepAvailabilityCheck, ];