What happened?
In packages/cli/src/gemini.test.tsx, the test 'should NOT load project hooks when workspace is not trusted' fails with
FatalUntrustedWorkspaceError whenever tests run in a non-TTY or automated environment (e.g. piped test runners, CI, background processes, or Windows
terminal environments where process.stdin.isTTY is undefined):
FAIL src/gemini.test.tsx > project hooks loading based on trust > should NOT load project hooks when workspace is not trusted
FatalUntrustedWorkspaceError: Gemini CLI is not running in a trusted directory. To proceed, either use --skip-trust, set the
GEMINI_CLI_TRUST_WORKSPACE=true environment variable, or trust this directory in interactive mode. For more details, see https://geminicli.
com/docs/cli/trusted-folders/#headless-and-automated-environments
❯ Object.check src/utils/userStartupWarnings.ts:98:13
❯ getUserStartupWarnings src/utils/userStartupWarnings.ts:122:20
❯ Module.main src/gemini.tsx:890:17
❯ src/gemini.test.tsx:1596:5
Root cause:
The test configures an untrusted workspace (isTrusted: false) expecting main() to load without project hooks. However, getUserStartupWarnings()
calls isHeadlessMode(). In non-TTY environments, isHeadlessMode() returns true, which immediately throws FatalUntrustedWorkspaceError and aborts
main() before reaching loadCliConfig.
Because packages/cli/src/gemini.test.tsx mocks @google/gemini-cli-core without mocking isHeadlessMode, it falls back to the unmocked
implementation and evaluates process.stdin.isTTY.
What did you expect to happen?
The unit test should mock isHeadlessMode: vi.fn(() => false) inside vi.mock('@google/gemini-cli-core') in gemini.test.tsx.
This ensures that the test simulates the interactive CLI startup path as intended and passes deterministically across all environments regardless of
TTY status.
Client information
Client Information
Run gemini to enter the interactive CLI, then run the /about command.
> /about
# paste output here
Login information
No response
Anything else we need to know?
I have a verified, 1-line fix ready: adding isHeadlessMode: vi.fn(() => false) to vi.mock('@google/gemini-cli-core') in packages/cli/src/gemini. test.tsx. All 44 tests in gemini.test.tsx pass cleanly with 0 typecheck and 0 lint errors.
Could a maintainer please add the help wanted label so I can self-assign (/assign) and open a pull request?
What happened?
In
packages/cli/src/gemini.test.tsx, the test 'should NOT load project hooks when workspace is not trusted' fails withFatalUntrustedWorkspaceErrorwhenever tests run in a non-TTY or automated environment (e.g. piped test runners, CI, background processes, or Windowsterminal environments where
process.stdin.isTTYis undefined):FAIL src/gemini.test.tsx > project hooks loading based on trust > should NOT load project hooks when workspace is not trusted
FatalUntrustedWorkspaceError: Gemini CLI is not running in a trusted directory. To proceed, either use
--skip-trust, set theGEMINI_CLI_TRUST_WORKSPACE=trueenvironment variable, or trust this directory in interactive mode. For more details, see https://geminicli.com/docs/cli/trusted-folders/#headless-and-automated-environments
❯ Object.check src/utils/userStartupWarnings.ts:98:13
❯ getUserStartupWarnings src/utils/userStartupWarnings.ts:122:20
❯ Module.main src/gemini.tsx:890:17
❯ src/gemini.test.tsx:1596:5
Root cause:
The test configures an untrusted workspace (
isTrusted: false) expectingmain()to load without project hooks. However,getUserStartupWarnings()calls
isHeadlessMode(). In non-TTY environments,isHeadlessMode()returnstrue, which immediately throwsFatalUntrustedWorkspaceErrorand abortsmain()before reachingloadCliConfig.Because
packages/cli/src/gemini.test.tsxmocks@google/gemini-cli-corewithout mockingisHeadlessMode, it falls back to the unmockedimplementation and evaluates
process.stdin.isTTY.What did you expect to happen?
The unit test should mock
isHeadlessMode: vi.fn(() => false)insidevi.mock('@google/gemini-cli-core')ingemini.test.tsx.This ensures that the test simulates the interactive CLI startup path as intended and passes deterministically across all environments regardless of
TTY status.
Client information
Client Information
Run
geminito enter the interactive CLI, then run the/aboutcommand.Login information
No response
Anything else we need to know?
I have a verified, 1-line fix ready: adding
isHeadlessMode: vi.fn(() => false)tovi.mock('@google/gemini-cli-core')inpackages/cli/src/gemini. test.tsx. All 44 tests ingemini.test.tsxpass cleanly with 0 typecheck and 0 lint errors.Could a maintainer please add the
help wantedlabel so I can self-assign (/assign) and open a pull request?