0

When I try to debug c++ file, I can't do it if it contains any spacebars in path to it (everything gets stuck at the "Starting build..."). for example: /home/vitaliy/Documents/My notes/a.cpp.

It stops in something like this: doesn't work

But if I remove spaces and my path will look like this: /home/vitaliy/Documents/Mynotes/a.cpp. It will work fine.

works fine

Here is my settigs.json:

{
"workbench.colorTheme": "Visual Studio Dark - C++",
"workbench.iconTheme": "vscode-icons",
"code-runner.runInTerminal": true,
"code-runner.saveFileBeforeRun": true,
"vsicons.dontShowNewVersionMessage": true,
"security.workspace.trust.untrustedFiles": "open",
"explorer.confirmDelete": false,
"editor.mouseWheelZoom": true,
"terminal.integrated.enableMultiLinePasteWarning": false,
"files.exclude": {
    "*.bin": true,
    "*.exe": true
},
"code-runner.saveAllFilesBeforeRun": true,
"code-runner.executorMap":{
    "javascript": "node",
    "java": "cd $dir && javac $fileName && java $fileNameWithoutExt",
    "c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "php": "php",
    "python": "python -u",
    "perl": "perl",
    "perl6": "perl6",
    "ruby": "ruby",
    "go": "go run",
    "lua": "lua",
    "groovy": "groovy",
    "powershell": "powershell -ExecutionPolicy ByPass -File",
    "bat": "cmd /c",
    "shellscript": "bash",
    "fsharp": "fsi",
    "csharp": "scriptcs",
    "vbscript": "cscript //Nologo",
    "typescript": "ts-node",
    "coffeescript": "coffee",
    "scala": "scala",
    "swift": "swift",
    "julia": "julia",
    "crystal": "crystal",
    "ocaml": "ocaml",
    "r": "Rscript",
    "applescript": "osascript",
    "clojure": "lein exec",
    "haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt",
    "rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt",
    "racket": "racket",
    "scheme": "csi -script",
    "ahk": "autohotkey",
    "autoit": "autoit3",
    "dart": "dart",
    "pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt",
    "d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt",
    "haskell": "runhaskell",
    "nim": "nim compile --verbosity:0 --hints:off --run",
    "lisp": "sbcl --script",
    "kit": "kitc --run",
    "v": "v run",
    "sass": "sass --style expanded",
    "scss": "scss --style expanded",
    "less": "cd $dir && lessc $fileName $fileNameWithoutExt.css",
    "FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt",
    "fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt"
},
"editor.bracketPairColorization.enabled": true,
"editor.accessibilitySupport": "off",
"audioCues.lineHasError": "off",
"audioCues.lineHasBreakpoint": "off",
"editor.fontFamily": "'DroidSansMono Nerd Font Mono'",
"settingsSync.ignoredSettings": [
    "editor.fontFamily"
],

}

The code I'm running:

#include <bits/stdc++.h>

using namespace std;

void solve() {
    cout << "adf as";
}

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t = 1;
    while(t--) solve();
}
user438383
  • 5,716
  • 8
  • 28
  • 43
IVKAR
  • 1
  • 1
  • What OS are you using? In windows, file path that have spaces in them need to be wrapped in quotes to tell the terminal it's all one symbol and the two parts of a command – NathanOliver Apr 26 '22 at 14:37
  • @NathanOliver I use manjaro GNOME on this PC. But I have same issue on my Windows 10 PC. – IVKAR Apr 26 '22 at 14:40
  • @Fureeish So, if yesterday (it really worked yesterday) I had everything working with gaps and today I don't, does that mean I've just been lucky? Am I right? If it's so, then it's answer for my question. – IVKAR Apr 26 '22 at 14:46
  • 1
    Because when you put the filename in the command (replace $fileName with the actual filename) the space makes it a different command. Do you see how it works? – user253751 Apr 26 '22 at 14:50
  • @user253751 Yeah, I see. But my file path is written in quotation marks and this should solve the problem, shouldn't it? – IVKAR Apr 26 '22 at 14:58
  • @VitaliyRyavkin But it's not written in quotation marks? – user253751 Apr 26 '22 at 14:59
  • 1
    @user253751 In the text of the question it isn't written (my bad), but in the screenshot they are there. (screenshot which named "doesn't work") – IVKAR Apr 26 '22 at 15:02
  • please include actual not working code that produces your problem. – Yakk - Adam Nevraumont Apr 26 '22 at 15:19
  • In your question, you say "When I try to debug", but in your screenshot (please don't post screenshots!), you show the build command - which should work, because the path is quoted. So what, exactly _is_ the problem? Is there an error message? And if so, what action triggers it? You should be able to copy and paste the relevant information from the relevant tab and add it to your question. – Paul Sanders Apr 26 '22 at 15:26
  • @PaulSanders Everything gets stuck at the "Starting build..." stage if there are gaps in the path, if not, the command executes successfully and I move on to debugging. No error message appears. – IVKAR Apr 26 '22 at 15:43
  • OK. Have you tried entering that build command at the command line? But the initial comment from @Fureeish sounds very relevant to me, are you _sure_ it ever worked? – Paul Sanders Apr 26 '22 at 15:47
  • @PaulSanders Yes, I tried to enter that command but it didn't do anything. I'm 100% sure it worked. My friend has directories with white spaces in it and c++ debugger has no problem (I asked him to try it a couple of hours ago). – IVKAR Apr 26 '22 at 16:04
  • OK, then I'm out of ideas, sorry. I don't use VS code, and for good reason. But if it's hanging up before actually performing the build then it doesn't sound like a problem with the debugger, that's about all I can tell you. If you're totally stuck, maybe take a look at something like [Eclipse](https://www.eclipse.org/ide/). From what little I know, it's probably a better bet. – Paul Sanders Apr 26 '22 at 16:18
  • @PaulSanders Thank you and everybody else! It was a matter of my curiosity. By and large, the problem is solved) – IVKAR Apr 26 '22 at 16:29
  • My advice is to never use a space in a path when programming in `c++` or `c`. The reason is in most cases your compile will use command line / shell tools to build and with these a space separates arguments causing the need to quote or escape the space. – drescherjm Apr 26 '22 at 18:00

0 Answers0