Skip to content

Fix long compilation command truncation in Compile Active File#4702

Open
Copilot wants to merge 2 commits intomainfrom
copilot/fix-truncated-compilation-command
Open

Fix long compilation command truncation in Compile Active File#4702
Copilot wants to merge 2 commits intomainfrom
copilot/fix-truncated-compilation-command

Conversation

Copy link
Contributor

Copilot AI commented Feb 9, 2026

This change addresses item #3575

This changes visible behavior

The following changes are proposed:

  • For compile commands exceeding 4000 characters, write the command to a temporary script file (.sh on Unix, .cmd on Windows) and execute that instead of passing it directly via terminal.sendText(), which silently truncates at ~4096 characters
  • Script files are automatically cleaned up after execution
  • Short commands continue to use sendText() directly (no behavior change)

The purpose of this change

terminal.sendText() has a ~4096 character input buffer limit imposed by terminal emulators. Complex C/C++ projects with many include paths can easily exceed this, causing the compilation command to be truncated — typically losing the source file argument at the end, which makes gcc fail.

The fix uses the same temp-script pattern already established in the codebase (visualStudio.ts, kit.ts).

Other Notes/Information

Files changed:

  • src/drivers/cmakeDriver.ts — Added createCompileScript() helper and length check in runCompileCommand()
  • CHANGELOG.md — Added bug fix entry under v1.23

Verification: CodeQL scan clean. Manual verification requires a project with a compilation database entry >4096 chars (e.g., thousands of -I flags).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • 0psvsblobprodwus2145.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --loglevel warn (dns block)
  • 2wrvsblobprodwus2180.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • 40vvsblobprodwus2135.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline (dns block)
  • 5bdvsblobprodwus2128.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED --loglevel warn (dns block)
  • 7t8vsblobprodwus2168.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
  • b15vsblobprodwus2164.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • b53vsblobprodwus2154.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • d94vsblobprodwus2119.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • ezcvsblobprodwus2170.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --prefer-offline (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
  • k4pvsblobprodwus2140.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
  • lusvsblobprodwus2166.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • n6wvsblobprodwus2123.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • p2tvsblobprodwus2189.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • pkwvsblobprodwus2126.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • v41vsblobprodwus2175.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /usr/local/bin/yarn install (dns block)
  • vm9vsblobprodwus2190.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
  • wztvsblobprodwus2155.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install --registry REDACTED 0 -j ACCEPT (dns block)
  • z2bvsblobprodwus2185.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • zt8vsblobprodwus2176.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)
  • zugvsblobprodwus2169.vsblob.vsassets.io
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node node /home/REDACTED/work/_temp/ghcca-node/node/bin/npm install (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Long compilation command truncated </issue_title>
<issue_description>### Brief Issue Summary

I have a C project with compilation database.
The project is very complex and has files with thousands of lines of code.
When running CMake: Compile Active File, the compilation command is spit into the newly created terminal, and below it a shell prompt with the same compilation command but truncated to 4096 (or 4095) characters.
The command fails because it is truncated and gcc cannot find which file to compile (which is.the last argument)
Running on vs code remote with ssh to ubuntu 20.04.

CMake Tools Diagnostics

No response

Debug Log

No response

Additional Information

No response</issue_description>

<agent_instructions>You are Copilot coding agent acting as a senior maintainer/contributor for the VS Code extension repository microsoft/vscode-cmake-tools.
You are deeply familiar with CMake, CMake Presets, CTest, kit/toolchain selection, VS Code extension APIs, and the architecture of this repo (TypeScript-heavy).
Your job is to resolve the GitHub issue provided below safely and in a maintainable way, matching existing patterns and UX.

SOURCE OF TRUTH

NON-NEGOTIABLE PROCESS

  1. Triage & understanding (issue-first)
  • Read the entire issue thread.
  • Extract and write down:
    • expected behavior
    • actual behavior
    • repro steps (or minimal repro you infer)
    • affected OS/toolchains/generators/presets
    • whether it is a regression and from which version/commit (if indicated)
  • Identify which CMake Tools feature area is involved (configure/build/test/debug, presets, kits, status bar, tasks, command palette, IntelliSense).
  1. Orient yourself in the repo (implementation map)
  • Identify the relevant user-facing workflows impacted (configure/build/test/debug, presets, kits, status bar, tasks, command palette).
  • Locate the existing implementation areas (commands, configuration/presets handling, test integration, UI, telemetry/logging).
  • Identify existing tests and how they are run in CI; prefer extending existing suites over inventing a new harness.
  1. Changelog discipline (required)
  • Find the project’s changelog / release notes mechanism (e.g., CHANGELOG.md, docs/changelog, “Unreleased” section, or a dedicated changes/ folder).
  • Add exactly ONE appropriate entry for this change, in the correct section and format used by the repo.
  • The entry must describe user-visible behavior (not internal refactors).
  • If the change is not user-visible, explicitly justify that and still add a brief “Internal” entry if the repo’s convention supports it.
  • Ensure the changelog entry matches wording/tense/category conventions already used by the repo.
  1. Implementation standards
  • Follow existing code style, naming, and patterns in this repository.
  • Prefer small, readable changes; avoid broad refactors unless clearly necessary to fix the issue correctly.
  • Preserve backward compatibility for settings/presets when possible; be careful with defaults and precedence rules.
  • Update docs/settings schema/messages if user-facing behavior or configuration changes.
  • Logging: use the extension’s existing logging utilities; avoid noisy output and avoid logging secrets/paths unnecessarily.
  1. Testing:
  • Create a unit test if possible AND practical to validate and test out fix, and ensure it is compatible with all platforms tested: Windows, Linux, and macOS. Ensure that it will not conflict with existing CI settings. If not possible to create a unit test, draft a manual plan for how to validate the changes worked.

Targeted scenario verification (must be addressed):

  • Verify via reasoning and/or scripted steps the relevant user flows, as applicable:
    • CMake configure with presets and without presets
    • Build, clean, reconfigure
    • Test discovery and execution (CTest)
    • Debugging (if impacted)
    • Multi-config generators (Ninja Multi-Config / Visual Studio) vs single-config
    • Windows/macOS/Linux differences if relevant
  1. PR hygiene + output requirements
  • PR title: concise, references the issue number.
  • PR description must include:
    • Problem summary (from the issue)
    • Root cause (where in code and why)
    • Fix summary (what changed)
    • Files changed (list + rationale)
    • Changelog entry text + location
    • Tests run (exact commands + results)
    • “How to test” / “How to verify” steps (step-by-step)
  • Link and close the issue (e.g., “Fixes #N”).
  • Do not mark the work complete until the changelog entry exists and tests/verification are documented.

QUALITY BAR / GOTCHAS TO...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

When running "CMake: Compile Active File", commands longer than ~4096
characters were truncated by the terminal's input buffer. For long
commands, write the command to a temporary script file and execute that
instead.

Fixes #3575

Co-authored-by: hanniavalera <90047725+hanniavalera@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix long compilation command truncation issue Fix long compilation command truncation in Compile Active File Feb 9, 2026
Copilot AI requested a review from hanniavalera February 9, 2026 15:30
@hanniavalera hanniavalera marked this pull request as ready for review February 9, 2026 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Long compilation command truncated

2 participants