15knots / cmake4eclipse

Let Eclipse use CMake to generate the buildscripts for Eclipse CDT
Eclipse Public License 2.0
85 stars 25 forks source link

"Resource '/home' does not exist." when trying to build #174

Closed eyalroz closed 2 years ago

eyalroz commented 2 years ago

Describe the bug

I'm importing a C++ project on Linux into Eclipse CDT 2022-03, after having just installed the latest cmake4eclipse.

When I try to build the project, or apply the cmake4eclipse settings, I get:

Parsing compilation database of project my_project has encountered a problem: [in a textbox:] Resource '/home' does not exist. Resource '/home' does not exist. [end textbox

Useful Information

15knots commented 2 years ago

Which language settings provider do you use? Is there something in the error log?

eyalroz commented 2 years ago

Which language settings provider do you use?

I don't know. How do I check?

Is there something in the error log?

Not sure. Here's the log in case you want to have a look.

Untitled.log

15knots commented 2 years ago

Thanks for the log. Indeed it contains the relevant stacktrace (at the end). The reported resource /home is not a file system path, it is the path of the project resource named home relative to the workspace. No idea, how that value gets in there. It is derived from the value of the 'Build output location' in the project properties. Usually, the value is _build/${ConfigName}.

eyalroz commented 2 years ago

@15knots :

  1. I didn't set this location myself, Eclipse did... meaning that cmake4eclipse needs to be able to live with it somehow. Actually, even if I were to set it - the add-on should still be able to live with it somehow...
  2. Looking at the project properties, I see the build location is: ${workspace_loc:/gpu-kernel-runner}/ (and the project name, and project directory name, is gpu-kernel-runner).
15knots commented 2 years ago

I debugged it with a different project and build location ${workspace_loc:/C-in-docker}/. Sth. like ${workspace_loc:/C-in-docker}/ gets expanded as an absolute file system path to /C-in-docker/home/xxx/devel/my/cmake4eclipse-sample-projects/C-in-docker. This value is interpreted as the name of a folder resource below the project resource which causes the error. Looks like CDT-MBS does not support to build in the project root directory.

eyalroz commented 2 years ago

I'm not sure I follow. What is MBS? And - I didn't make any settings myself, so - does CDT not support building using the default settings it makes? Sorry for being clueless here.

Pudel-des-Todes commented 2 years ago

Encounter the same problem while trying to add "CMake Compilation DB" provider to an already existing project. It seems that an error happened because I have "Generate Makefiles automatically" unchecked (and in my case, it has to be unchecked), and the build directory was set to ${workspace_loc:my_project}/build/Debug, which looked absolutely fine on the first glance. The only thing that helped is to change the build directory to my_project/build/Debug. It looks like the compilation database parser always treats the build directory path as relative, even if it is set as absolute by eclipse variables.

SidManning commented 2 years ago

I have the exact same issue. I created the default Hello World cmake project in /tmp built it then deleted the project but kept the source. I then imported the same project "Existing Code as Makefile Project" and see the error: Resource '/tmp' does not exist. Resource '/tmp' does not exist.

If I do the same thing with a project located in, "/local/mnt/workspace/eclipse-workspace/hello2" I get a similar error except the resource name is "/local" , this is the error: Resource '/local' does not exist. Resource '/local' does not exist.

SidManning commented 2 years ago

Previously, Manage Configurations would include Release/Debug, if my memory is correct, now it only includes "Default" I don't know if this common or unique to my installation or not. Pudel-des-Todes, thank you for your observation that allows me to work again however I still think there is some problem because I don't remember having to do that before.

15knots commented 2 years ago

Looks like CDT-MBS does not support to build in the project root directory.

MBS stands for Managed Build System (as opposed to Core Build and Make Build)

15knots commented 2 years ago

Encounter the same problem while trying to add "CMake Compilation DB" provider to an already existing project. It seems that an error happened because I have "Generate Makefiles automatically" unchecked (and in my case, it has to be unchecked), and the

If you uncheck it, you effectively disable cmake4eclipse.

havoc-dlt commented 2 years ago

Exact same problem here. "Resource '/home' does not exist." two times, not much else. @15knots: Have you been able to find out where exactly in your code this gets interpreted?

cmake4eclipse version: 3.0.5 cmake version 3.24.1 Eclipse IDE for C/C++ Developers (includes Incubating components) Version: 2022-06 (4.24.0) Build id: 20220609-1112 OS: Linux, v.5.19.5-arch1-1, x86_64 / gtk 3.24.34 Java vendor: Eclipse Adoptium Java runtime version: 17.0.3+7 Java version: 17.0.3

havoc-dlt commented 2 years ago

Previously, Manage Configurations would include Release/Debug, if my memory is correct, now it only includes "Default" I don't know if this common or unique to my installation or not. Pudel-des-Todes, thank you for your observation that allows me to work again however I still think there is some problem because I don't remember having to do that before.

Can confirm this as well.

Pudel-des-Todes commented 2 years ago

If you uncheck it, you effectively disable cmake4eclipse.

I'm fully aware of that. Unfortunately, I have to work on projects with MCU vendor-specific nature (STM32 MCU projects, to be specific) that replace the standard Tool Chain Editor with their own, which makes cmake4eclipse almost unusable anyway. However, I'm still able to use "CMake Compilation DB" provider (the thing that parses "compile_commands.json" and provides include paths and defines to the Indexer).

15knots commented 2 years ago

@Pudel-des-Todes

It looks like the compilation database parser always treats the build directory path as relative, even if it is set as absolute by eclipse variables.

Yes, it does. Just as the label on the input field states.

If you do not want to have the build output below the project root directory, create a linked resource in the workbench properties, then click the 'Create...' button in the project properties page, click 'Advanced' in the 'New Folder' dialog, check 'Link to folder...' and insert the variable that references your linked resource.

15knots commented 2 years ago

Looks like sometimes our buildscript generator is not kicked in and a non-absolute path is generated. MBS`s Builder.getDefaultBuildPath() does then generate a garbled variable expression{workspaceloc:/my-project-name}/buildroot. After variable-expansion this is/home/user/my-project-name/buildroot` which denotes a file system path, but not a eclipse workbench resource. Hence the "Resource '/home' does not exist."_ error.