18

I get this message when I click on a warning. This is a screenshot of the case. enter image description here

The error reads,

Unable to open 'warning.cpp': Unable to read file '/Users/dimen/code/C++/Users/dimen/code/C++/warning.cpp' (Error: Unable to resolve non-existing file '/Users/dimen/code/C++/Users/dimen/code/C++/warning.cpp').

My script is located in /Users/dimen/code/C++/warning.cpp so vscode reiterates the path for some reason.

I suspected that the linter setting must've been written erroneously but I'm not sure where I should edit. As some side notes,

  • Using Microsoft's C/C++ extension.
  • tasks.json have been customized so that all the builds go inside the build folder
AVANISH RAJBHAR
  • 527
  • 3
  • 9
Dimen
  • 391
  • 1
  • 4
  • 18

6 Answers6

8

I was facing this issue also.

For resolving this issue, I closed the VSCode and again imported folder again as Path of folder got changed in mine conditions.

If this doesn't work, you can uninstall VSCode and then reinstall it.

desertnaut
  • 57,590
  • 26
  • 140
  • 166
NowRam
  • 150
  • 2
  • 5
4

You need to edit the problemMatcher part of tasks.json so that it has a variable called fileLocation that is set to absolute. Here is an example of what it should look like:

"problemMatcher": {
    "base" : "$gcc",
    "fileLocation" : "absolute"
}

I hope this helps.

aggserp4
  • 57
  • 1
  • 7
3

Check this link. It seems to require detailed configurations for the directory. In task.json the problemMatcher takes the file directory as relative so you got repeating path. Setting "fileLocation" to "absolute" works on my laptop.

Jason
  • 31
  • 2
0

For me this worked in tasks.json:

{
    "tasks": [
        {
            //"type": "cppbuild",
            "label": "build my project",
            "command": "/home/user/path/build.bash",
            "args": [
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": {
                "base": "$gcc",
                "fileLocation": "absolute",
            },
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}

For some reason i had to specifically remove "type": "cppbuild" for it to work.

Andrei Pokrovsky
  • 3,590
  • 3
  • 26
  • 17
0

I fixed this issue by making a change in 'launch.json' file. I changed the value of "cwd" below "name": "(gdb) Launch eds" in "configurations" field. I set it to the absolute path of the folder containing the project. Below is my launch.json file. I'm using VS Code on Ubuntu.

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "(gdb) Launch eds",
            "type": "cppdbg",
            "request": "launch",
            "program": "${workspaceFolder}/build_x86_debug/bin/fcc",
            "args": ["-a=${workspaceFolder}/build_x86_debug/bin/", "-d=${workspaceFolder}/build_x86_debug/bin/", "-c=${workspaceFolder}/build_x86_debug/bin/"],
            "stopAtEntry": false,
            "cwd": "/home/aiden/dev2",
            "environment": [{"name": "LD_LIBRARY_PATH", "value": "/usr/lib:${workspaceFolder}/build_x86_debug/bin:${workspaceFolder}/pocolib1.7.5"}],
            "externalConsole": false,
            "MIMode": "gdb",
            "setupCommands": [
                {
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ]
        },
        {
            "name": "Launch",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/build_x86/bin/emvadapter",
            "cwd" : "/home/vendor",
            "env" : { "LD_LIBRARY_PATH":"/home/vendor/lib" }

        },
        {
            "name": "Unit Tests",
            "type": "lldb",
            "request": "launch",
            "program": "${workspaceFolder}/build_x86/bin/",
            "linux": { "cwd": "${workspaceFolder}/vendor"}
        }
    ]
}
Aiden
  • 1
  • 3
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 14 '21 at 05:32
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/29817520) – Rishabh Deep Singh Sep 14 '21 at 08:37
0

I got this too on ApiLogicServer, which uses this feature extensively.

Took a few, but this resolved it by clicking container (lower left) and then rebuild-container:

enter image description here

val
  • 139
  • 1
  • 6