Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build command ignores puncutations in source path #11422

Closed
shashwatrathod opened this issue Sep 9, 2023 · 3 comments
Closed

Build command ignores puncutations in source path #11422

shashwatrathod opened this issue Sep 9, 2023 · 3 comments
Assignees
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service tasks/build/debug An issue relating to tasks.json (e.g. build issues)
Milestone

Comments

@shashwatrathod
Copy link

shashwatrathod commented Sep 9, 2023

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. 
@Colengms
Copy link
Contributor

Hi @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.

@Colengms Colengms added bug Language Service tasks/build/debug An issue relating to tasks.json (e.g. build issues) labels Sep 11, 2023
@Colengms Colengms added this to the 1.18 milestone Sep 11, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.18, 1.19 Nov 9, 2023
@browntarik browntarik added the fixed Check the Milestone for the release in which the fix is or will be available. label Nov 30, 2023
@sean-mcmanus sean-mcmanus modified the milestones: 1.19, 1.19.2 Jan 16, 2024
@sean-mcmanus
Copy link
Contributor

@Colengms
Copy link
Contributor

Hi @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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service tasks/build/debug An issue relating to tasks.json (e.g. build issues)
Projects
None yet
Development

No branches or pull requests

4 participants