Skip to content

Build command ignores puncutations in source path #11422

Closed

Description

Environment

  • OS and Version: Windows 11 with WSL 2 running Ubuntu 20.04.4
  • VS Code Version: 1.81.1
  • C/C++ Extension Version: 1.17.5
  • If using SSH remote, specify OS of remote machine: N/A

Bug Summary and Steps to Reproduce

Bug Summary:
If the source path contains punctuation, the extension's build command ignores the punctuation in that path. Since the entered file path doesn't exist a 'No such file or directory' error is thrown.

Steps to reproduce:

  1. Create a new directory Sept'23 (Notice the ').
  2. Create a new .cpp file inside this directory (helloworld.cpp)
  3. Try to trigger the build using the 'Run' button on the top-right corner of VSCode's nav bar.

The build will fail and you should see a 'No such file or directory' error in the terminal.

Expected behavior:
The build command uses the source path /path/to/Sept23/helloworld.cpp instead of /path/to/Sept'23/helloworld.cpp due to which it fails. The punctuation should have been taken into account.

Configuration and Logs

{
  "configurations": [
    {
      "name": "Linux",
      "includePath": ["${workspaceFolder}/**"],
      "defines": [],
      "compilerPath": "/usr/bin/g++",
      "cStandard": "c17",
      "cppStandard": "gnu++14",
      "intelliSenseMode": "linux-gcc-x64"
    }
  ],
  "version": 4
}

Other Extensions

No response

Additional context

Here is part of the terminal output:

Starting build...
/usr/bin/g++ -fdiagnostics-color=always -g /mnt/d/Shashwat/Fall'23/main.cpp -o /mnt/d/Shashwat/Fall'23/main
g++: error: /mnt/d/Shashwat/Fall'23/main.cpp -o /mnt/d/Shashwat/Fall'23/main: No such file or directory
g++: fatal error: no input files
compilation terminated.

Build finished with error(s).

 *  The terminal process failed to launch (exit code: -1). 
 *  Terminal will be reused by tasks, press any key to close it. 

Activity

  1. Colengms commented on Sep 11, 2023

    @Colengms
    Contributor

    Hi Shashwat Rathod (@shashwatrathod) . Thanks for reporting this. It looks like this path is not properly escaped to account for shell command-line special characters before being used in a shell command line.

  2. added
    fixedCheck the Milestone for the release in which the fix is or will be available.
    on Nov 30, 2023
  3. sean-mcmanus commented on Jan 22, 2024

    @sean-mcmanus
    Contributor
  4. Colengms commented on Feb 28, 2024

    @Colengms
    Contributor

    Hi Shashwat Rathod (@shashwatrathod) . With 1.19.5, we're aligning the behavior of args and command fields in tasks.json with the behavior of VS Code's shell task type, which is documented here. When upgrading to 1.19.5, I believe you'll need to modify the generated tasks.json to provide an explicit quoting behavior, as described in that documentation.

    Aligning this behavior with VS Code's default task type should provide a consistent user experience, and allow us to drive any shortcoming of that approach as issues with VS Code itself, and not behavior specific to the extension. If the new behavior turns out to be problematic for you, I'd suggest following up with an issue in the VS Code repo.

  5. locked and limited conversation to collaborators on Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.tasks/build/debugAn issue relating to tasks.json (e.g. build issues)

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions