question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to open source file outside workspaceFolder from project outline

See original GitHub issue

hi @bobbrow, I am using 1.4.2 CMake Tools on macOS, but the issue is still there:

Unable to open 'main.cpp': Unable to read file '/Users/admin/Projects/A/console/Users/admin/Projects/A/src/main.cpp' (Error: Unable to resolve non-existing file '/Users/admin/Projects/A/console/Users/admin/Projects/A/src/main.cpp').

The project structure looks like:

A $ tree -L 2 .
.
├── README.md
├── console
│   ├── build
│   └── CMakeLists.txt
├── src
│   └── main.cpp
└── third-party

with this simple setup:

set(MAIN_SOURCE_DIR "../src")

file(GLOB_RECURSE CPP_HEADERS ${MAIN_SOURCE_DIR}/*.hpp)
file(GLOB_RECURSE CPP_SOURCES ${MAIN_SOURCE_DIR}/*.cpp)

add_executable(
    A
    ${CPP_HEADERS}
    ${CPP_SOURCES}
)

As you can see, the error reports a path with <CMakeLists Dir>+<Absolute Source Path>, which is duplicate and totally wrong.

'/Users/admin/Projects/A/console/Users/admin/Projects/A/src/main.cpp'

Platform and Versions Operating System:macOS CMake Version:3.18.4 VSCode Version:1.50.1 CMake Tools Extension Version: 1.4.2 Compiler/Toolchain: Clang 11

_Originally posted by @mutoo in https://github.com/microsoft/vscode-cmake-tools/issues/1254#issuecomment-713215418_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
andreeiscommented, May 5, 2021

@sleiner, your contribution is in 👍. If all goes according to plans, we should release CMake Tools 1.7.2 tomorrow. Until then, here’s a vsix with your change, if needed: https://github.com/microsoft/vscode-cmake-tools/actions/runs/814930130.

1reaction
k0pernicuscommented, Nov 6, 2020

Hi everyone, I have the exact same issue than @bobbrow (EDIT: sorry, it was @mutoo).

If I don’t make any mistake, we are following a tutorial to create a sort of graphic engine on multiple platforms, using C++ and SDL: https://marcelbraghetto.github.io/a-simple-triangle/2019/03/02/part-02/

In this part, the author shows how to configure it’s own VSCode instance using Cmake and Cmake Tools (vector-of-bool version, not from microsoft), but following the steps VSCode + extensions does not follow the rules and create another full path inside the current workspace folder.

I expect that the configuration of the extensions change, or something we missed, because using the scripts on the console directly works, check the code directly and build the binary.

Setup:

  • macOS Catalina 10.15.7
  • VSCode 1.50.1
  • CMake (twxs) version 0.0.17
  • CMake Tools (Microsoft) version 1.5.0
Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging unable to open source files - Stack Overflow
So, debugger cann't open the source file, because it looks into /proc/self/cwd/external folder which doesn't exists.
Read more >
Debug Node.js Apps using Visual Studio Code
Setting up a project for Node.js debugging is straightforward with VS Code providing appropriate launch configuration defaults and snippets.
Read more >
How to manually configure Visual Studio Code for Debugging ...
Open Folder in Visual Studio Code and write a C++ program ... In the main VS Code editor, click on File -> New...
Read more >
Project Import and Build errors in CCS
Explains how to fix Code Composer Studio (CCS) project import errors and build errors and ... Error: could not open source file "xxx.h"....
Read more >
Opening source files in Visual Studio Code - Microsoft Learn
If you work on a local project and you have Microsoft Visual Studio Code installed, you can open files in this one instead...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found