Skip to content

fix(cli): fallback to TERMUX_ORIGINAL_EXE_PATH to prevent linker64 crash in Termux#27563

Open
Gong-Mi wants to merge 1 commit into
google-gemini:mainfrom
Gong-Mi:fix/termux-linker64-bug
Open

fix(cli): fallback to TERMUX_ORIGINAL_EXE_PATH to prevent linker64 crash in Termux#27563
Gong-Mi wants to merge 1 commit into
google-gemini:mainfrom
Gong-Mi:fix/termux-linker64-bug

Conversation

@Gong-Mi
Copy link
Copy Markdown
Contributor

@Gong-Mi Gong-Mi commented May 29, 2026

This fixes the issue where termux-exec replaces the process.execPath with linker64, causing Node.js spawn to fail when arguments start with a dash. We now use TERMUX_ORIGINAL_EXE_PATH if available.

@Gong-Mi Gong-Mi requested a review from a team as a code owner May 29, 2026 16:00
@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 29, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves a critical issue affecting Node.js applications running within Termux, where the process.execPath was incorrectly modified, causing child process spawning to fail. By prioritizing the TERMUX_ORIGINAL_EXE_PATH environment variable, the system now correctly identifies the original Node.js executable, ensuring reliable execution of commands and preventing application crashes.

Highlights

  • Termux Compatibility Fix: Implemented a fallback mechanism to TERMUX_ORIGINAL_EXE_PATH when spawning child processes in Termux environments. This addresses an issue where termux-exec replaces process.execPath with linker64, leading to Node.js spawn failures when arguments start with a dash.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for Termux environments by checking the TERMUX_ORIGINAL_EXE_PATH environment variable when spawning child processes, falling back to process.execPath if it is not defined. The reviewer suggests trimming the TERMUX_ORIGINAL_EXE_PATH environment variable across all modified files (index.ts, processUtils.ts, and relaunch.ts) to robustly handle empty or whitespace-only strings and ensure a safe fallback.

Comment thread packages/cli/index.ts
Comment on lines +104 to +105
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
const child = spawn(execPath, spawnArgs, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

To prevent issues where the TERMUX_ORIGINAL_EXE_PATH environment variable might be set to an empty or whitespace-only string, we should trim the value before checking its truthiness. This ensures a robust fallback to process.execPath in all invalid environment configurations.

Suggested change
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
const child = spawn(execPath, spawnArgs, {
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH']?.trim() || process.execPath;
const child = spawn(execPath, spawnArgs, {
References
  1. When using an optional string with a fallback value, trim the optional string and use the fallback if the result is empty to avoid uninformative messages from whitespace-only strings.

Comment on lines 112 to +115
// We explicitly use process.execPath to break the cycle and prevent
// compounding argument duplication on subsequent relaunches.
finalSpawnArgs.push(process.execPath, ...scriptArgs);
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
finalSpawnArgs.push(execPath, ...scriptArgs);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

We should trim the TERMUX_ORIGINAL_EXE_PATH environment variable to safely handle empty or whitespace-only values. Additionally, let's update the comment to refer to the resolved executable path generally rather than hardcoding process.execPath in the description, keeping the documentation accurate.

Suggested change
// We explicitly use process.execPath to break the cycle and prevent
// compounding argument duplication on subsequent relaunches.
finalSpawnArgs.push(process.execPath, ...scriptArgs);
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
finalSpawnArgs.push(execPath, ...scriptArgs);
// We explicitly use the executable path to break the cycle and prevent
// compounding argument duplication on subsequent relaunches.
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH']?.trim() || process.execPath;
finalSpawnArgs.push(execPath, ...scriptArgs);
References
  1. When using an optional string with a fallback value, trim the optional string and use the fallback if the result is empty to avoid uninformative messages from whitespace-only strings.

Comment on lines +59 to +60
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
const child = spawn(execPath, spawnArgs, {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Trim the TERMUX_ORIGINAL_EXE_PATH environment variable to ensure that any empty or whitespace-only values correctly fall back to process.execPath and do not cause spawn failures.

Suggested change
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH'] || process.execPath;
const child = spawn(execPath, spawnArgs, {
const execPath = process.env['TERMUX_ORIGINAL_EXE_PATH']?.trim() || process.execPath;
const child = spawn(execPath, spawnArgs, {
References
  1. When using an optional string with a fallback value, trim the optional string and use the fallback if the result is empty to avoid uninformative messages from whitespace-only strings.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant