5 / 6
Apr 7

whenever i try to build the mongocxx 4.0 driver using the instructions online on my debian 12 vm (works fine in ubuntu 22), it gives me the folllowing errors.

Please help. i have absolutely no idea why this wont work

user@debian:~/Downloads/mongo-cxx-driver-r4.0.0/build$ cmake … -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=17
– No MongoDB C Driver path provided via CMAKE_PREFIX_PATH, will download C driver version 1.29.0 from the internet.
– Download and configure C driver version 1.29.0 … begin
[ 11%] Performing update step for ‘mongo-c-driver-populate’
CMake Error at /home/user/Downloads/mongo-cxx-driver-r4.0.0/build/_deps/mongo-c-driver-subbuild/mongo-c-driver-populate-prefix/tmp/mongo-c-driver-populate-gitupdate.cmake:25 (message):
Failed to get the hash for HEAD:

fatal: not a git repository: ‘.git’

gmake[2]: *** [CMakeFiles/mongo-c-driver-populate.dir/build.make:130: mongo-c-driver-populate-prefix/src/mongo-c-driver-populate-stamp/mongo-c-driver-populate-update] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/mongo-c-driver-populate.dir/all] Error 2
gmake: *** [Makefile:91: all] Error 2

CMake Error at /usr/share/cmake-3.25/Modules/FetchContent.cmake:1616 (message):
Build step for mongo-c-driver failed: 2
Call Stack (most recent call first):
/usr/share/cmake-3.25/Modules/FetchContent.cmake:1756:EVAL:2 (__FetchContent_directPopulate)
/usr/share/cmake-3.25/Modules/FetchContent.cmake:1756 (cmake_language)
/usr/share/cmake-3.25/Modules/FetchContent.cmake:1970 (FetchContent_Populate)
cmake/FetchMongoC.cmake:39 (FetchContent_MakeAvailable)
CMakeLists.txt:78 (include)

– Configuring incomplete, errors occurred!

Using a later cmake version fails differently:

– Download and configure C driver version 1.29.0 … end
CMake Warning (dev) at CMakeLists.txt:207 (find_package):
Policy CMP0148 is not set: The FindPythonInterp and FindPythonLibs modules
are removed. Run “cmake --help-policy CMP0148” for policy details. Use
the cmake_policy command to set the policy and suppress this warning.

This warning is for project developers. Use -Wno-dev to suppress it.

– Found PythonInterp: /usr/bin/python3.11 (found version “3.11.2”)
fatal: not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File “/home/user/Downloads/mongo-cxx-driver-r4.0.0/etc/calc_release_version.py”, line 370, in
RELEASE_VER = main()
^^^^^^
File “/home/user/Downloads/mongo-cxx-driver-r4.0.0/etc/calc_release_version.py”, line 325, in main
head_commit_short = check_output([‘git’, ‘rev-parse’, ‘–revs-only’,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/home/user/Downloads/mongo-cxx-driver-r4.0.0/etc/calc_release_version.py”, line 131, in check_output
raise subprocess.CalledProcessError(ret, args[0])
subprocess.CalledProcessError: Command ‘git’ returned non-zero exit status 128.
CMake Error at CMakeLists.txt:220 (message):
BUILD_VERSION not specified and could not be calculated (script invocation
failed); specify in CMake command, -DBUILD_VERSION=

Do you have any network restrictions? Seems like the auto-download of C driver is failing. Also check if you have git installed.

i do have git installed, and as far as i know i have no network restrictions that would prevent a git repo from being downloaded

the error seems to be saying that there isnt a git repo. i can see the source code being downloaded properly into the _deps folder. so it shouldnt be me failing to download the source

okay, seems to be related to https://www.mongodb.com/community/forums/t/mongo-cxx-driver-4-0-0-error-when-building-from-source-on-linux-mint/307094

If the build folder gets deleted from the tarball (which i was doing to clean the build between attempts), it will fail with the above error. Someone should probably modify the tarball and setup process so that this doesnt happen… since in basically every other situation, the build folder is entirely made up of generated files, and is therefore safe to delete for cleaning