Skip to content

fix(cli): resolve bunx execution -S not found error on Windows#24653

Closed
ilkerozgedik wants to merge 0 commit intogoogle-gemini:mainfrom
ilkerozgedik:main
Closed

fix(cli): resolve bunx execution -S not found error on Windows#24653
ilkerozgedik wants to merge 0 commit intogoogle-gemini:mainfrom
ilkerozgedik:main

Conversation

@ilkerozgedik
Copy link
Copy Markdown

@ilkerozgedik ilkerozgedik commented Apr 3, 2026

Summary

Fixed execution failure on Windows when running bunx @google/gemini-cli. The shebang #!/usr/bin/env -S node --no-warnings=DEP0040 uses the -S flag which is a GNU env extension not supported on Windows, causing:

error: interpreter executable "-S" not found in %PATH%

Details

  • Replaced shebang with #!/usr/bin/env node in both entry points (packages/cli/index.ts, packages/a2a-server/src/http/server.ts)
  • Moved DEP0040 (punycode deprecation) suppression to a dedicated suppress-warnings.ts module that is imported first — this correctly handles ESM module hoisting, ensuring the override runs before any other module is evaluated

Related Issues

Closes #24654

How to Validate

On a Windows machine:

  • Run bunx @google/gemini-cli — should launch without any error
  • Previously would fail with: error: interpreter executable "-S" not found in %PATH%

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt
    • Windows
      • npm run
      • npx
      • Docker
    • Linux
      • npm run
      • npx
      • Docker

@ilkerozgedik ilkerozgedik requested review from a team as code owners April 3, 2026 23:31
@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 addresses a compatibility issue where the use of the -S flag in shebang lines caused execution errors on Windows systems when using tools like bunx. By shifting the suppression of deprecation warnings from the shebang to a runtime programmatic check, the project ensures a more robust and cross-platform execution experience for developers.

Highlights

  • Shebang Update: Removed the unsupported -S flag from the shebang lines in executable files to ensure compatibility with Windows environments.
  • Warning Suppression: Implemented a programmatic interception of process.emitWarning to suppress DEP0040 (punycode deprecation) warnings, replacing the previous command-line flag approach.
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 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 counter productive. 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.

@google-cla
Copy link
Copy Markdown

google-cla bot commented Apr 3, 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.

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 replaces shebang-based warning suppression with a manual override of process.emitWarning in packages/a2a-server/src/http/server.ts and packages/cli/index.ts to ensure compatibility across platforms like Windows. The review feedback correctly identifies that due to ESM hoisting, static imports are evaluated before the suppression logic, which may allow deprecation warnings to leak during the initial module load. The reviewer suggests using dynamic imports or a dedicated initialization module to ensure the override is active before any dependencies are processed.

Comment on lines 9 to 20
// Suppress DEP0040 (Punycode deprecation warning) safely, as Windows limits shebang flags.
const originalEmitWarning = process.emitWarning;
process.emitWarning = ((...args: unknown[]) => {
const [warning, type, code] = args;
if (type === 'DEP0040' || code === 'DEP0040' || (type === 'DeprecationWarning' && String(warning).includes('punycode'))) {
return;
}
return Reflect.apply(originalEmitWarning, process, args);
}) as typeof process.emitWarning;

import * as url from 'node:url';
import * as path from 'node:path';
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

In ECMAScript Modules (ESM), static import statements are hoisted and evaluated before the module body runs. This means the process.emitWarning override will execute only after all static imports (including those on lines 22-23 and their transitive dependencies) have been fully evaluated. If any of these modules trigger the punycode deprecation warning during their evaluation, the suppression will be ineffective.

To correctly suppress warnings during module loading in ESM, you should either:

  1. Move the suppression logic to a separate file and import it as the very first import in this file.
  2. Use dynamic import() for all dependencies after the override logic.
References
  1. When a new file is intended to replace a file that will be deprecated, it is acceptable to duplicate definitions from the old file to avoid creating a dependency on the code that is being phased out.

Comment on lines 9 to 21
// Suppress DEP0040 (Punycode deprecation warning) safely, as Windows limits shebang flags.
const originalEmitWarning = process.emitWarning;
process.emitWarning = ((...args: unknown[]) => {
const [warning, type, code] = args;
if (type === 'DEP0040' || code === 'DEP0040' || (type === 'DeprecationWarning' && String(warning).includes('punycode'))) {
return;
}
return Reflect.apply(originalEmitWarning, process, args);
}) as typeof process.emitWarning;

import { main } from './src/gemini.js';
import { FatalError, writeToStderr } from '@google/gemini-cli-core';
import { runExitCleanup } from './src/utils/cleanup.js';
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

In ESM, static import statements are hoisted and evaluated before the module body. Consequently, the process.emitWarning override will run after the modules on lines 19-21 have been loaded, making the suppression ineffective if they trigger the warning during evaluation. Using dynamic import() ensures the override is active before the modules are loaded.

// Suppress DEP0040 (Punycode deprecation warning) safely, as Windows limits shebang flags.
const originalEmitWarning = process.emitWarning;
process.emitWarning = ((...args: unknown[]) => {
  const [warning, type, code] = args;
  if (type === 'DEP0040' || code === 'DEP0040' || (type === 'DeprecationWarning' && String(warning).includes('punycode'))) {
    return;
  }
  return Reflect.apply(originalEmitWarning, process, args);
}) as typeof process.emitWarning;

const { main } = await import('./src/gemini.js');
const { FatalError, writeToStderr } = await import('@google/gemini-cli-core');
const { runExitCleanup } = await import('./src/utils/cleanup.js');

@gemini-cli gemini-cli bot added the status/need-issue Pull requests that need to have an associated issue. label Apr 3, 2026
@ilkerozgedik ilkerozgedik force-pushed the main branch 2 times, most recently from c7f8351 to 4ad792c Compare April 4, 2026 00:32
@ilkerozgedik ilkerozgedik changed the title fix: resolve bunx execution -S error on Windows fix(cli): resolve bunx execution -S not found error on Windows Apr 4, 2026
@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality and removed status/need-issue Pull requests that need to have an associated issue. labels Apr 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: interpreter executable -S not found when running via bunx on Windows

1 participant