Skip to content

fix(vscode): use tsx for 'Run Current File' debug configuration#25220

Open
AjayBora002 wants to merge 5 commits intogoogle-gemini:mainfrom
AjayBora002:fix/vscode-run-current-file-ts
Open

fix(vscode): use tsx for 'Run Current File' debug configuration#25220
AjayBora002 wants to merge 5 commits intogoogle-gemini:mainfrom
AjayBora002:fix/vscode-run-current-file-ts

Conversation

@AjayBora002
Copy link
Copy Markdown

@AjayBora002 AjayBora002 commented Apr 12, 2026

The 'Launch Program' debug configuration used program: , which fails for .ts/.tsx files since Node.js cannot execute TypeScript natively. Updated to use pm exec tsx which leverages the project's existing tsx dependency for runtime transpilation.

Fixes #22844

Summary

Updated the VS Code debug configuration so you can actually hit F5 on a .ts
file and have it run without blowing up.

Details

The old config had "program": "${file}" which just hands the file to Node.js
directly. That works for .js files but not for TypeScript.
The fix swaps it to use tsx (which is already in the project's devDependencies
at ^4.20.3 and is used by several npm scripts). I also added cwd and
NODE_ENV=development to keep it consistent with the other debug configs in
the file.

Related Issues

Fixes #22844

How to Validate

  1. Open the project in VS Code
  2. Open any .ts file (e.g. something under packages/cli/src/)
  3. Select "CLI: Run Current File" from the debug dropdown
  4. Hit F5 — it should run without any TypeScript syntax errors

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed) — not applicable, config-only change
  • Added/updated tests (if needed) — not applicable, this is a VS Code config file
  • Noted breaking changes (if any) — none
  • Validated on required platforms/methods:
    • Windows
      • npm run

@AjayBora002 AjayBora002 requested a review from a team as a code owner April 12, 2026 15:56
@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 improves the developer experience in VS Code by enabling direct execution of TypeScript files through the debugger. By switching from direct Node.js execution to using 'tsx', the configuration now correctly handles TypeScript files, resolving issues where the debugger would fail to run them.

Highlights

  • Debug Configuration Update: Updated the 'CLI: Run Current File' debug configuration to use 'tsx' via 'npm exec' instead of direct Node.js execution.
  • Environment Consistency: Added 'cwd' and 'NODE_ENV=development' to the debug configuration to ensure consistency with existing project settings.
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 12, 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 adds a new VS Code launch configuration, 'CLI: Run Current File', to facilitate running and debugging individual files. Feedback was provided regarding the use of npm exec as the runtime executable, which interferes with the debugger's ability to attach. The reviewer suggested using node with the --import tsx flag for better performance and debugging support, along with configuring the integrated terminal for correct CLI output rendering.

Note: Security Review has been skipped due to the limited scope of the PR.

Comment thread .vscode/launch.json
Comment on lines +44 to +54
"name": "CLI: Run Current File",
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeExecutable": "npm",
"runtimeArgs": ["exec", "tsx", "--", "${file}"],
"cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"],
"program": "${file}",
"outFiles": ["${workspaceFolder}/**/*.js"]
"outFiles": ["${workspaceFolder}/**/*.js"],
"env": {
"NODE_ENV": "development"
}
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

Using npm exec as the runtimeExecutable in a launch.json configuration is problematic for debugging. VS Code's Node.js debugger attempts to inject debugging flags (such as --inspect-brk) into the runtimeExecutable. Since npm does not recognize these flags, it will likely fail to start or ignore them, preventing the debugger from attaching to the actual script process. This means breakpoints will not work as expected.

Additionally, npm exec introduces significant startup overhead. Since this project uses Node.js 20 (recommended ~20.19.0 per the repository style guide), the preferred approach is to use node directly with the --import tsx flag.

Furthermore, since this is a CLI project using Ink, you should set "console": "integratedTerminal" to ensure the output is rendered correctly in a TTY-enabled environment, consistent with other configurations in this file (e.g., lines 15, 72, 90).

Suggested change
"name": "CLI: Run Current File",
"type": "node",
"request": "launch",
"name": "Launch Program",
"runtimeExecutable": "npm",
"runtimeArgs": ["exec", "tsx", "--", "${file}"],
"cwd": "${workspaceFolder}",
"skipFiles": ["<node_internals>/**"],
"program": "${file}",
"outFiles": ["${workspaceFolder}/**/*.js"]
"outFiles": ["${workspaceFolder}/**/*.js"],
"env": {
"NODE_ENV": "development"
}
"name": "CLI: Run Current File",
"type": "node",
"request": "launch",
"program": "${file}",
"runtimeArgs": ["--import", "tsx"],
"cwd": "${workspaceFolder}",
"console": "integratedTerminal",
"skipFiles": ["<node_internals>/**"],
"env": {
"NODE_ENV": "development"
}
References
  1. The project recommends Node.js ~20.19.0 for development, which supports the --import flag for loaders. (link)

@gemini-cli gemini-cli bot added area/core Issues related to User Interface, OS Support, Core Functionality area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support! labels Apr 12, 2026
@AjayBora002 AjayBora002 force-pushed the fix/vscode-run-current-file-ts branch 2 times, most recently from e24f86d to 62b8f0e Compare April 13, 2026 14:30
The 'Launch Program' debug configuration used program: , which fails for .ts/.tsx files since Node.js cannot execute TypeScript natively. Updated to use
pm exec tsx which leverages the project's existing tsx dependency for runtime transpilation.

Fixes google-gemini#22844
@AjayBora002 AjayBora002 force-pushed the fix/vscode-run-current-file-ts branch from 62b8f0e to 890946c Compare April 13, 2026 14:40
@AjayBora002 AjayBora002 reopened this Apr 16, 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 area/extensions Issues related to Gemini CLI extensions capability help wanted We will accept PRs from all issues marked as "help wanted". Thanks for your support!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix TypeScript execution in “CLI: Run Current File” debug configuration

1 participant