launch.json solved

i had a problem in VScode cpp build , it always failed and pop up

then i click Debug Anyway then pops up

i stressed alot and try to setup .vscode folder many times.

i tried to build the cpp file using many shells , i tried cmd and it didn’t w…


This content originally appeared on DEV Community and was authored by ziad Z3TAR

i had a problem in VScode cpp build , it always failed and pop up

then i click Debug Anyway then pops up

i stressed alot and try to setup .vscode folder many times.

i tried to build the cpp file using many shells , i tried cmd and it didn't work ,pwsh also didn't work ,finally i Used the shell of the MSYS2 MINGW64 because that the one i setup it,and it works✨.

i tried to make the file build and run inside VScode using the MSYS2 MINGW64 shell it self instead of making it runs through pwsh,and i manage it by .vscode/settings.json:

{
    "terminal.integrated.profiles.windows": {
        "bash (MSYS2)": {
            "path": "C:\\msys64\\usr\\bin\\bash.exe",
            "args": [
                "-l",
                "-i"
            ],
            "env": {
                "MSYSTEM": "MINGW64"
            },
            "icon": "terminal-bash"
        }
    },
    "terminal.integrated.defaultProfile.windows": "bash (MSYS2)",
    "editor.formatOnSave": true
}

this made the default shell is MINGW64

THE LAST PIECE OF PUZZLE (THE REAL PROBLEM)

i find that after setting up the tasks.json & launch.json that ✨finally✨ it run inside VScode it self , i was so happy and copy and paste the .vscode folder everywhere , but something weird happened , sometimes it build and run , and somtimes it fails due to the same previous error (the two popup messages in the start), i was shocked "is the error wasn't in the build or what"
finally , i found the real hidden problem (that you should try now if you had the same pop up messages) is QUADRATIC QUOTES , yep
inside tasks.json , you probably has :

            "args": [
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}.exe"
            ],

and this is the problem , when this path passed to the shell ; it passed without the "" , why ?
because these quotes was the json string quotes , mean that when it passed to the shell and run ; it runs without quotes , and this can cause path problem if it has space or special chars .
the solution is quadratic quotes :

"args": [
    "\"${file}\"",
    "-o",
    "\"${fileDirname}/${fileBasenameNoExtension}.exe\""
]

by this , two quotes will be removed and still be additional quotes to passed as "----" to the shell which solve the "no such file or directory with name ext..." error

I wish my story help someone to setup cpp in VScode


This content originally appeared on DEV Community and was authored by ziad Z3TAR


Print Share Comment Cite Upload Translate Updates
APA

ziad Z3TAR | Sciencx (2025-10-04T10:36:41+00:00) launch.json solved. Retrieved from https://www.scien.cx/2025/10/04/launch-json-solved-2/

MLA
" » launch.json solved." ziad Z3TAR | Sciencx - Saturday October 4, 2025, https://www.scien.cx/2025/10/04/launch-json-solved-2/
HARVARD
ziad Z3TAR | Sciencx Saturday October 4, 2025 » launch.json solved., viewed ,<https://www.scien.cx/2025/10/04/launch-json-solved-2/>
VANCOUVER
ziad Z3TAR | Sciencx - » launch.json solved. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/04/launch-json-solved-2/
CHICAGO
" » launch.json solved." ziad Z3TAR | Sciencx - Accessed . https://www.scien.cx/2025/10/04/launch-json-solved-2/
IEEE
" » launch.json solved." ziad Z3TAR | Sciencx [Online]. Available: https://www.scien.cx/2025/10/04/launch-json-solved-2/. [Accessed: ]
rf:citation
» launch.json solved | ziad Z3TAR | Sciencx | https://www.scien.cx/2025/10/04/launch-json-solved-2/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.