Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to resolve includes from "external" targets #6495

Open
sid-kumar-figure opened this issue Jun 20, 2024 · 6 comments
Open

Unable to resolve includes from "external" targets #6495

sid-kumar-figure opened this issue Jun 20, 2024 · 6 comments
Assignees
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: c++ C++ rules integration product: CLion CLion plugin type: bug

Comments

@sid-kumar-figure
Copy link

Description of the bug:

Clion is unable to find any of my included targets from "external" targets that are imported in WORKSPACE.
I am running Clion with a Dev Container.

Example:

Clion cannot find flexi_cfg/reader.h :

image

Which I have included via this git_repository rule in WORKSPACE:

git_repository(
    name = "flexi_cfg",
    build_file = "@//:third_party/flexi_cfg/build_file.bazel",
    commit = "4b3aab37b97dccd099213b040dcb5375f1654b84",  # main (v0.5.0)
    remote = "https://github.com/miker2/flexi_config_reader.git",
)

This is the build_file content just for completeness:

package(default_visibility = ["//visibility:public"])

cc_library(
    name = "flexi_cfg",
    srcs = [
      "src/config_helpers.cpp",
      "src/config_parser.cpp",
      "src/config_reader.cpp",
      "src/math_helpers.cpp",
    ],
    hdrs = glob(["include/**"]),
    includes = ["include"],
    visibility = ["//visibility:public"],
    tags = ["no-clang-tidy", "manual"],
    deps = [
      "@range-v3",
      "@pegtl",
      "@fmt",
      "@magic_enum",
    ]
)

I can manually see the file :

$ ls -lha /home/xxx/.cache/bazel/_bazel_xxx/d9fd8dd9485b3d1d1994c3846baefa35/external/flexi_cfg/include/flexi_cfg/
total 48K
drwxr-xr-x 4 xxx xxx 4.0K Jun  7 15:35 .
drwxr-xr-x 3 xxx xxx 4.0K Jun  7 15:35 ..
drwxr-xr-x 2 xxx xxx 4.0K Jun  7 15:35 config
-rw-r--r-- 1 xxx xxx 5.3K Jun  7 15:35 logger.h
drwxr-xr-x 2 xxx xxx 4.0K Jun  7 15:35 math
-rw-r--r-- 1 xxx xxx 2.4K Jun  7 15:35 parser.h
-rw-r--r-- 1 xxx xxx 8.3K Jun  7 15:35 reader.h
-rw-r--r-- 1 xxx xxx 5.0K Jun  7 15:35 utils.h

Which category does this issue belong to?

CLion

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

I'm fairly new to using Bazel in Clion, But atleast in my setup you can reproduce this problem by importing any "external" library/package in WORKSPACE and trying to include a header file from that library/package.

Which Intellij IDE are you using? Please provide the specific version.

Clion 2024.1.3

What programming languages and tools are you using? Please provide specific versions.

Language: C++

What Bazel plugin version are you using?

2024.06.04.0.2-api-version-241

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@sid-kumar-figure sid-kumar-figure added awaiting-maintainer Awaiting review from Bazel team on issues type: bug labels Jun 20, 2024
@github-actions github-actions bot added the product: CLion CLion plugin label Jun 20, 2024
@iancha1992 iancha1992 added the lang: c++ C++ rules integration label Jun 20, 2024
@LeFrosch
Copy link
Collaborator

Hi, I was not able to reproduce your issue. Can you try new_git_repository instead of git_repository?

@sid-kumar-figure
Copy link
Author

sid-kumar-figure commented Jun 26, 2024

So I tried that but I had no luck, is there an easy way to see what include paths are being provided by the plugin to Clion to allow it to find an included header? .. This was just an example but I have multiple third party/external libraries that are imported in via rules in the WORKSPACE file; using new_local_repository, new_git_repository and http_archive that are not being found/resolved by Clion's intellisense ..

Couple of other things; I am using Clion in the Dev Container mode so I'm not sure if that is supported, also I have tried this with VSCode's Bazel plugin and it seems to do fine at resolving these includes, though I do prefer using CLion so I'm hoping theres a way to get this working .

@tpasternak
Copy link
Contributor

@sid-kumar-figure could you share your OS and Bazel version, too?

@sid-kumar-figure
Copy link
Author

OS is Ubuntu 22.04 LTS
bazel version: 7.0.2

@LeFrosch
Copy link
Collaborator

LeFrosch commented Jul 8, 2024

Hi, sorry for the late response. I tried to reproduce your issue by connecting to a remote machine using ssh. So far everything is still working in my case.

You can see all the include paths and more for a file when you run the Show Compiler Info action. Could you maybe share the first part Compiler switches and the bottom part Header Search paths?

Btw easiest way to find this action is to search for it.

@sid-kumar-figure
Copy link
Author

sid-kumar-figure commented Jul 11, 2024

I apologize for the later reply.

I think the Dev Container workflow in Clion is a little different from the Remote machine workflow. (https://www.jetbrains.com/help/clion/connect-to-devcontainer.html)

Here is the requested info:

Compiler switches:

	-U_FORTIFY_SOURCE
	--target=x86_64-unknown-linux-gnu
	-U_FORTIFY_SOURCE
	-fstack-protector
	-fno-omit-frame-pointer
	-fcolor-diagnostics
	-Wall
	-Wthread-safety
	-Wself-assign
	-g0
	-O2
	-D_FORTIFY_SOURCE=1
	-DNDEBUG
	-ffunction-sections
	-fdata-sections
	-std=c++17
	-stdlib=libstdc++
	-march=x86-64-v3
	-I
	/workspaces/project-x/.
	-Wall
	-Wextra
	-Wpedantic
	-Wno-sign-compare
	-Wno-gcc-compat
	-Wno-c99-extensions
	-Werror
	-Wno-error=unused-result
	-Wno-error=gnu-statement-expression
	-Wno-error=unused-command-line-argument
	-Wno-error=unused-parameter
	-Wno-error=deprecated-declarations
	-Wno-error=sometimes-uninitialized
	-Wno-error=unused-variable
	-Wno-error=pessimizing-move
	-Wno-error=return-type
	-Wno-error=string-plus-int
	-Wno-error=pedantic
	-Wno-error=inconsistent-missing-override
	-Wno-error=unused-function
	-g
	--std=c++20
	-no-canonical-prefixes
	-Wno-builtin-macro-redefined
	-D__DATE__="redacted"
	-D__TIMESTAMP__="redacted"
	-D__TIME__="redacted"
	-fdebug-prefix-map=external/llvm_toolchain_llvm/=__bazel_toolchain_llvm_repo__/
	-iquote/workspaces/project-x/.
		-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/fmt
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_google_googletest
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/eigen3
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/magic_enum
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/tl_expected
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_google_absl
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/com_google_absl
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/range-v3
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/spdlog
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_github_google_flatbuffers
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/com_github_google_flatbuffers
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/etl
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/fit
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/fit
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/folly
	-iquote/home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/bazel_tools
Header Search paths:
	Pointer(user): file:///workspaces/project-x
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/fmt
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_google_googletest
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/eigen3
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/magic_enum
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/tl_expected
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_google_absl
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/com_google_absl
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/range-v3
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/spdlog
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/com_github_google_flatbuffers
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/com_github_google_flatbuffers
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/etl
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/fit
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/execroot/_main/bazel-out/k8-opt-release/bin/external/fit
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/folly
	Pointer(user): file:///home/clion/.cache/bazel/_bazel_clion/d9fd8dd9485b3d1d1994c3846baefa35/external/bazel_tools
	Pointer: file:///workspaces/project-x
	Pointer: file:///usr/include/c++/11
	Pointer: file:///usr/include/x86_64-linux-gnu/c++/11
	Pointer: file:///usr/include/c++/11/backward
	Pointer
	Pointer: file:///usr/local/include
	Pointer: file:///usr/include/x86_64-linux-gnu
	Pointer: file:///usr/include

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting-maintainer Awaiting review from Bazel team on issues lang: c++ C++ rules integration product: CLion CLion plugin type: bug
Projects
None yet
Development

No branches or pull requests

8 participants