g++ “ignoring nonexistant directory” that does in fact exist (only with CLion + Ninja)

I have some C++ source which includes the line:

#include <Eigen/Core>

The compilation fails at this line, with the error: (my source file names/paths redacted for brevity.)

In file included from ___.h:8,
                 from ___.cpp:1:
____.hpp:5:10: fatal error: Eigen/Core: No such file or directory
    5 | #include <Eigen/Core>
      |          ^~~~~~~~~~~~~~~~~~~
compilation terminated.

The strange thing is that building this from the command line (even using the Ninja file that CLion generated) works fine.

My CMakeLists.txt includes the following:

include_directories("/usr/local/include" "/usr/local/opt/llvm/include"
        "/usr/include/eigen3" "/usr/include/eigen3/unsupported"
        "include/" "include/minidnn" )

Most relevant are the two eigen-related paths. Under /usr/include/eigen3 is (I have triple checked) a folder called Eigen, within which is a file named Core. This is the reason that I believe this build system should work. As mentioned, this does work when not building through CLion.

To try and debug this, I added --verbose to the g++ flags. Here is the relresult:

ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include-fixed/x86_64-linux-gnu"
ignoring nonexistent directory "/usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../x86_64-unknown-linux-gnu/include"
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/usr/local/opt/llvm/include"
ignoring nonexistent directory "/usr/include/eigen3"
ignoring nonexistent directory "/usr/include/eigen3/unsupported"
#include "..." search starts here:
#include <...> search starts here:
 /home/garby/Documents/code/cpp/shared-memory-sgd/include
 /home/garby/Documents/code/cpp/shared-memory-sgd/include/minidnn
 /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../include/c++/13.2.0
 /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../include/c++/13.2.0/x86_64-unknown-linux-gnu
 /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/../../../../include/c++/13.2.0/backward
 /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
Compiler executable checksum: 783eab82059e8c1c7db8dfb100492c35
In file included from /home/garby/Documents/code/cpp/shared-memory-sgd/include/minidnn/NetworkExecutor.h:8,
                 from /home/garby/Documents/code/cpp/shared-memory-sgd/semisync.cpp:1:
/home/garby/Documents/code/cpp/shared-memory-sgd/include/minidnn/ParameterContainer.h:5:10: fatal error: Eigen/Core: No such file or directory
    5 | #include <Eigen/Core>
      |          ^~~~~~~~~~~~
compilation terminated.

This seems strange. Most of the directories that g++ is claiming are “nonexistant” are absolutely existant. For instance, /usr/local/include and /usr/include/eigen3 exist. The permissions on these files/directories also look acceptable:

drwxr-xr-x 1 root root 100 Feb  2  2022 /usr/include/eigen3/
drwxr-xr-x 1 root root 584 Feb  2  2022 /usr/include/eigen3/Eigen/
-rw-r--r-- 1 root root 12799 Feb  2  2022 /usr/include/eigen3/Eigen/Core

For completeness, here is the full command which is invoked by Ninja (under CLion) before it fails.

/usr/bin/g++  -I/usr/local/include -I/usr/local/opt/llvm/include -I/usr/include/eigen3 -I/
usr/include/eigen3/unsupported -I/home/garby/Documents/code/cpp/shared-memory-sgd/include 
-I/home/garby/Documents/code/cpp/shared-memory-sgd/include/minidnn -fopenmp -g --verbose 
-std=gnu++20 -fdiagnostics-color=always -MD -MT CMakeFiles/mininn.dir/semisync.cpp.o 
-MF CMakeFiles/mininn.dir/semisync.cpp.o.d -o CMakeFiles/mininn.dir/semisync.cpp.o 
-c /home/garby/Documents/code/cpp/shared-memory-sgd/semisync.cpp

If I run this command manually, from the terminal, that source file builds correctly(!) This, I believe, is the crux of the problem. CLion must be doing something strange when it comes to path resolution. Does it execute inside some kind of container?…

(While writing this, I discovered the answer. I’ll post the question anyway, and post the answer too, just in case anyone else comes across the same problem.)

Just after I wrote that it’s as if CLion is running in some kind of container, I remembered that maybe I installed it with flatpak. I usually try to avoid flatpak (due to exactly this kind of issue), but this was indeed the case here.

Flatpak restricts which directories applications may access, in this case too harshly. This explains g++ not finding the include directories.

In theory, I think the solution to this can be the following:

flatpak override --filesystem=host com.jetbrains.CLion

Although this didn’t work for me… My solution was uninstalling flatpak’s CLion and just running it from a downloaded tar, which I also don’t enjoy.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật