Skip to content

compilerPath setting of c_cpp_properties.json no longer supports batch files #3428

Closed

Description

@smhc

Type: LanguageService

Describe the bug

  • OS and Version: Windows 10
  • VS Code Version: 1.33.0
  • C/C++ Extension Version: 0.22.1

compilerPath setting of c_cpp_properties.json no longer supports batch files (.bat). Earlier versions did support these. Using "cmd /C call xx.bat" works, however it is not possible to pass "${workspaceFolder}" as an argument.

Using a batch file results in the misleading error:
Failed to spawn process. Error: 2 (The system cannot find the file specified.)

To Reproduce

Use a c_cpp_properties.json file with a setting of:

"compilerPath":  "${workspaceFolder}\\test.bat"

or:

"compilerPath": "C:\\Windows\\System32\\cmd.exe /C echo ${workspaceFolder} >> %TEMP%\\cmd.log"

Expected behavior

Either the batch file can be launched directly, or at least make it possible to pass the 'workspaceFolder' as an argument to cmd to launch a batch file.

Additional context

The reason I wish to launch a batch file from the workspace folder is I want to have a 'dummy compiler' included as part of the project. This dummy compiler just returns the include paths and defines etc as gcc/g++ would. I use this technique for remote development from windows to linux with 'correct' intellisense.
However recent versions of vscode/cpptools have blocked this ability.

Activity

  1. sean-mcmanus commented on Apr 8, 2019

    @sean-mcmanus
    Contributor

    Sorry about that -- we had a bunch of bugs in this scenario. It should be fixed for our next release, but it probably won't make the soon to be released 0.22.2-insiders.

  2. smhc commented on Apr 8, 2019

    @smhc
    Author

    Could you elaborate on which fix was implemented:

    • compilerPath now supports batch files
    • compilerPath now supports multiple replacements of ${workspaceFolder} in the arg list

    Cheers.

  3. sean-mcmanus commented on Apr 9, 2019

    @sean-mcmanus
    Contributor

    We fixed it so that .cmd/.bat files works in the command line, as well as cmd.exe with args that are paths surrounded by quotes (which was also buggy, which I assume is why your cmd.exe workaround didn't work).

    We didn't fix the ${workspaceFolder} issue, i.e. we only resolve that variable when it's at the start of the compilerPath and not as an argument. If that will still be an issue for you, can you file a new bug for that?

  4. smhc commented on Apr 9, 2019

    @smhc
    Author

    Ok thanks.
    The 'cmd /C call' workaround did work ok, It's just that I couldn't use the workspaceFolder as part of the args. e.g

    cmd /C call ${workspaceFolder}\\dummy_compiler.bat
    

    But being able to run a batch file directly is sufficient. Using:

    ${workspaceFolder}\\dummy_compiler.bat
    

    Once can simply use the CWD within the batch file to use it how you like. Thanks.

  5. sean-mcmanus commented on Apr 9, 2019

    @sean-mcmanus
    Contributor

    Yeah, using cmd should work as a workaround for now, assuming there are no spaces or double quotes (bug fix pending) or ${workspaceFolder} in your path (no bug fix pending currently, semi "by design")

  6. smhc commented on Apr 9, 2019

    @smhc
    Author

    While I don't specifically need multiple substitution of ${workspaceFolder} - I did read a similar request on another issue. I am adding the link here for prosperity:

    #1982 (comment)

    I imagine the ability to invoke a batch file and use CWD would be a workaround for most scenarios.

  7. sean-mcmanus commented on Apr 9, 2019

    @sean-mcmanus
    Contributor

    Thanks for letting me know about that other user's report -- the restriction on ${workspaceFolder} to be only be resolved at the beginning was an oversight that was trivial to fix as well (#3440 ).

  8. sean-mcmanus commented on Apr 24, 2019

    @sean-mcmanus
    Contributor

    The .bat file should work on 0.23.0-insiders now, but we didn't check in the fix for ${workspaceFolder} in the compilerPath yet (should be in 0.23.1-insiders).

  9. locked and limited conversation to collaborators on Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.quick fixregressionA bug that didn't exist in a previous release

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions