franneck94 / Vscode-C-Cpp-Runner

🚀 Compile, run and debug single or multiple C/C++ files with ease. 🚀
MIT License
53 stars 14 forks source link

[BUG] Local compiler path gets overwritten #80

Closed fronders closed 2 years ago

fronders commented 2 years ago

For one of the projects I want to use not gcc but i686-w64-mingw32-gcc (to cross compile for windows), which is present under /usr/bin/i686-w64-mingw32-gcc, but the moment I edit the compiler path and save the local to workspace .settings file it gets overwritten to default gcc.

What I'm trying to save in the .settings:

{
  "C_Cpp_Runner.cCompilerPath": "i686-w64-mingw32-gcc",
  "C_Cpp_Runner.cppCompilerPath": "i686-w64-mingw32-g++",
  "C_Cpp_Runner.debuggerPath": "gdb",
  "C_Cpp_Runner.cStandard": "",
  "C_Cpp_Runner.cppStandard": "",
  "C_Cpp_Runner.msvcBatchPath": "",
  "C_Cpp_Runner.useMsvc": false,
  "C_Cpp_Runner.warnings": [
    "-Wall",
    "-Wextra",
    "-Wpedantic"
  ],
  "C_Cpp_Runner.enableWarnings": true,
  "C_Cpp_Runner.warningsAsError": false,
  "C_Cpp_Runner.compilerArgs": [],
  "C_Cpp_Runner.linkerArgs": [],
  "C_Cpp_Runner.includePaths": [],
  "C_Cpp_Runner.includeSearch": [
    "*",
    "**/*"
  ],
  "C_Cpp_Runner.excludeSearch": [
    "**/build",
    "**/build/**",
    "**/.*",
    "**/.*/**",
    "**/.vscode",
    "**/.vscode/**"
  ],
}

in a blink of an eye it goes back to

{
  "C_Cpp_Runner.cCompilerPath": "gcc",
  "C_Cpp_Runner.cppCompilerPath": "g++",
  "C_Cpp_Runner.debuggerPath": "gdb",
  "C_Cpp_Runner.cStandard": "",
  "C_Cpp_Runner.cppStandard": "",
  "C_Cpp_Runner.msvcBatchPath": "",
  "C_Cpp_Runner.useMsvc": false,
  "C_Cpp_Runner.warnings": [
    "-Wall",
    "-Wextra",
    "-Wpedantic"
  ],
  "C_Cpp_Runner.enableWarnings": true,
  "C_Cpp_Runner.warningsAsError": false,
  "C_Cpp_Runner.compilerArgs": [],
  "C_Cpp_Runner.linkerArgs": [],
  "C_Cpp_Runner.includePaths": [],
  "C_Cpp_Runner.includeSearch": [
    "*",
    "**/*"
  ],
  "C_Cpp_Runner.excludeSearch": [
    "**/build",
    "**/build/**",
    "**/.*",
    "**/.*/**",
    "**/.vscode",
    "**/.vscode/**"
  ]
}

and c_cpp_properties.json

{
  "configurations": [
    {
      "name": "linux-gcc-x64",
      "includePath": [
        "${workspaceFolder}/**"
      ],
      "compilerPath": "/usr/bin/gcc",
      "cStandard": "${default}",
      "cppStandard": "${default}",
      "intelliSenseMode": "linux-gcc-x64",
      "compilerArgs": [
        ""
      ]
    }
  ],
  "version": 4
}

Even if I set the compiler paths on user level settings, local workspace still gets overwritten to gcc \ g++

franneck94 commented 2 years ago

Have you tried using absolute paths to the compiler?

SzFl commented 2 years ago

I confirm what fronders said, but with little difference. I have just installed vs code and added this extension. Unfortunately in file settings.json I do not know why, but the path to gcc and g++ instead of being like you said in manual (/usr/bin/g++ ) is /usr/bin/core_perl/g++. It looks like instead of setting path like in manual it (on my machine) added first file in bin file and than started to looking for g++.

BuG

Every change in settings.json is overwritten back.

Absolute Paths do not help.

I am noobie with vs code, but I hope this was helpful.

franneck94 commented 2 years ago

Does it work in the newest version?

fronders commented 2 years ago

With newest version (4.0.7) it still gets overwritten. Once I was able to make it stay custom with entering the full path. But then if I changed it back to /usr/bin/gcc it kept rolling it back to custom. Wasn't able to reproduce it next times (closing vscode, deleting the .vscode folder and reopening + selecting folder to init). Still overrides em to gcc and g++. c_cpp_properties still had /usr/bin/gcc the whole time

UPD: Finally was able to reproduce - it stays custom if I superquickly change both settings and c_cpp_properties until it gets overwritten

franneck94 commented 2 years ago

Does it work when you only change to your custom path in the properties? This should be then synched to the settings file.

On my win/lin i cannot reproduce this currently

fronders commented 2 years ago

No, changing it only in c_cpp_properties.json to full path does not change settings.json automatically. And after some time it changes c_cpp_properties to /usr/bin/gcc

franneck94 commented 2 years ago

I confirm what fronders said, but with little difference. I have just installed vs code and added this extension. Unfortunately in file settings.json I do not know why, but the path to gcc and g++ instead of being like you said in manual (/usr/bin/g++ ) is /usr/bin/core_perl/g++. It looks like instead of setting path like in manual it (on my machine) added first file in bin file and than started to looking for g++.

BuG

Every change in settings.json is overwritten back.

Absolute Paths do not help.

I am noobie with vs code, but I hope this was helpful.

Is also for you still an issue?

franneck94 commented 2 years ago

Since i cannot reproduce this...

fronders commented 2 years ago

Since i cannot reproduce this...

I have the same problem also when running under WSL, did you try to reproduce it that way?

franneck94 commented 2 years ago

The only reason that it can get overwritten is maybe that the path where the compiler is, is not in your PATH

franneck94 commented 2 years ago

Since i cannot reproduce this...

I have the same problem also when running under WSL, did you try to reproduce it that way?

What exact compiler names and paths?

fronders commented 2 years ago

sorry, on a field trip, will get back to you with this on Thursday

franneck94 commented 2 years ago

Any update?

fronders commented 2 years ago

Sorry for the delay. Tried again on WSL from scratch in a new folder, and looks like the issue is fixed, probably was caused by some caching (deleting .vscode helped only when folder was not open as a workspace)