gemini-cli - 💡(How to fix) Fix Unhandled Promise Rejection (ENAMETOOLONG) when pasting multiline text logs [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
google-gemini/gemini-cli#25618Fetched 2026-04-19 15:22:52
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×3commented ×1mentioned ×1

Error Message

The CLI's input parsing logic incorrectly identifies the pasted multiline string as a local file path and passes it to Node.js fs.realpathSync / fs.lstat. This exceeds the OS filename length limit, triggering an ENAMETOOLONG error. The lack of error handling (try-catch) for this filesystem operation causes the fatal crash. │ ℹ Keychain initialization encountered an error: libsecret-1.so.0: cannot open shared object file: No such file or directory │ │ This is an unexpected error. Please file a bug report using the /bug tool. │ │ Reason: Error: ENAMETOOLONG: name too long, lstat '/mnt/lib/tide-packages/grimler.se>" imported │ │ Error: ENAMETOOLONG: name too long, lstat '/mnt/lib/tide-packages/grimler.se>" imported │

Code Example

> /about
About Gemini CLI│                                                                                                                                                  │
CLI Version                                       0.38.1Git Commit                                        7f5580034                                                                                      │
Model                                             gemini-3.1-flash-lite-preview                                                                  │
Sandbox                                           no sandbox                                                                                     │
OS                                                linux                                                                                          │
Auth Method                                       Signed in with Google (2696596951ykd@gmail.com)Tier                                              Gemini Code Assist for individuals                                                             │
# paste output here
RAW_BUFFERClick to expand / collapse

What happened?

When pasting multiline text (such as a build log) containing certain string patterns like [email protected] followed by line breaks, the CLI crashes with an Unhandled Promise Rejection.

The CLI's input parsing logic incorrectly identifies the pasted multiline string as a local file path and passes it to Node.js fs.realpathSync / fs.lstat. This exceeds the OS filename length limit, triggering an ENAMETOOLONG error. The lack of error handling (try-catch) for this filesystem operation causes the fatal crash.

Environment:

Package version: @google/[email protected] os:6.12.74+deb13+1-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.12.74-2 (2026-03-08) x86_64 GNU/Linux

What did you expect to happen?

The CLI should treat the pasted multiline log purely as standard string input for the prompt. If the parser attempts to resolve local paths, it should include proper try...catch blocks around fs module operations to gracefully handle invalid paths or OS-level ENAMETOOLONG errors without crashing the application.

Client information

<details> <summary>Client Information</summary>

Run gemini to enter the interactive CLI, then run the /about command.

> /about
About Gemini CLI                                                                                                                                 │
│                                                                                                                                                  │
│ CLI Version                                       0.38.1                                                                                         │
│ Git Commit                                        7f5580034                                                                                      │
│ Model                                             gemini-3.1-flash-lite-preview                                                                  │
│ Sandbox                                           no sandbox                                                                                     │
│ OS                                                linux                                                                                          │
│ Auth Method                                       Signed in with Google ([email protected])                                                │
│ Tier                                              Gemini Code Assist for individuals                                                             │
# paste output here
</details>

Login information

No response

Anything else we need to know?

Debug Console (F12 to close) │ │ │ │ ℹ Keychain initialization encountered an error: libsecret-1.so.0: cannot open shared object file: No such file or directory │ │ │ │ ℹ Using FileKeychain fallback for secure storage. │ │ │ │ ℹ Loaded cached credentials. │ │ │ │ ℹ Detected terminal background color: #000000 │ │ │ │ ℹ Detected terminal name: Warp(v0.2026.04.15.08.45.stable_02) │ │ │ │ ℹ Enabling Kitty keyboard protocol │ │ ℹ Authenticated via "oauth-personal". │ │ ✖ ========================================= │ │ This is an unexpected error. Please file a bug report using the /bug tool. │ │ CRITICAL: Unhandled Promise Rejection! │ │ ========================================= │ │ Reason: Error: ENAMETOOLONG: name too long, lstat '/mnt/lib/tide-packages/grimler.se>" imported │ │ gpg: Total number processed: 1 │ │ gpg: imported: 1 │ │ gpg: no ultimately trusted keys found │ │ gpg (GnuPG) 2.4.4; Copyright (C) 2024 g10 Code GmbH │ │ This is free software: you are free to change and redistribute it. │ │ There is NO WARRANTY, to the extent permitted by law. │ │ gpg: key 5A897D96E57CF20C: public key "Termux' │ │ Stack trace: │ │ Error: ENAMETOOLONG: name too long, lstat '/mnt/lib/tide-packages/grimler.se>" imported │ │ gpg: Total number processed: 1 │ │ gpg: imported: 1 │ │ gpg: no ultimately trusted keys found │ │ gpg (GnuPG) 2.4.4; Copyright (C) 2024 g10 Code GmbH │ │ This is free software: you are free to change and redistribute it. │ │ There is NO WARRANTY, to the extent permitted by law. │ │ gpg: key 5A897D96E57CF20C: public key "Termux' │ │ at Module.realpathSync (node:fs:2729:29) │ │ at robustRealpath │ │ (file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/chunk-ETUADTWF.js:41905:16) │ │ at resolveToRealPath │ │ (file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/chunk-ETUADTWF.js:41896:10) │ │ at checkPermissions │ │ (file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/chunk-C3HWPYQ6.js:60877:30) │ │ at │ │ file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/interactiveCli-EOCVNM6H.js:48651:37 │ │ at │ │ file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/interactiveCli-EOCVNM6H.js:37035:7 │ │ at Object.handleSubmit │ │ (file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/interactiveCli-EOCVNM6H.js:34562:9 │ │ ) │ │ at │ │ file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/interactiveCli-EOCVNM6H.js:37084:20 │ │ at │ │ file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/interactiveCli-EOCVNM6H.js:37623:13 │ │ at file:///mnt/lib/data/pnpm/global/5/.pnpm/@[email protected]/node_modules/@google/gemini-cli/bundle/chunk-C3HWPYQ6.js:51170:15 │ │ │ │

extent analysis

TL;DR

The CLI crashes due to an Unhandled Promise Rejection when pasting multiline text containing certain string patterns, caused by incorrect input parsing and lack of error handling for filesystem operations.

Guidance

  • The issue is likely caused by the CLI's input parsing logic incorrectly identifying the pasted multiline string as a local file path, exceeding the OS filename length limit and triggering an ENAMETOOLONG error.
  • To mitigate this, the input parsing logic should be updated to correctly handle multiline strings and avoid passing them to filesystem operations.
  • Error handling (try-catch blocks) should be added around fs module operations to prevent crashes due to invalid paths or OS-level errors.
  • The fs.realpathSync and fs.lstat functions should be wrapped in try-catch blocks to catch and handle ENAMETOOLONG errors.

Example

try {
  const realpath = fs.realpathSync(pastedString);
  // ...
} catch (error) {
  if (error.code === 'ENAMETOOLONG') {
    console.error('Error: Input string is too long to be treated as a file path.');
  } else {
    throw error;
  }
}

Notes

The provided stack trace and error message indicate that the issue is related to the fs.realpathSync and fs.lstat functions, which are used to resolve file paths. The lack of error handling for these operations causes the CLI to crash when an ENAMETOOLONG error occurs.

Recommendation

Apply a workaround by adding try-catch blocks around fs module operations to prevent crashes due to invalid paths or OS-level errors, until a permanent fix can be implemented to correct the input parsing logic.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING