Skip to content

FetchContent_MakeAvailable fails to clone private repositories #462

Open
@jshellen

Description

@jshellen

TLDR:
CMake configuration step fails to FetchContent_MakeAvailable when trying to clone a private repository.

Background:
We have a C++ project which uses CMake and FetchContent to manage external dependencies. All external dependencies are contained in private repositories under our own organization. We are trying to automate unit testing using GitHub Actions but are unable to make this work due to the fact that FetchContent_MakeAvailable fails when trying to clone into private repositories.

cmake.yml

name: CMake
on: [push]
env:
  BUILD_TYPE: Release

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2

    - name: Install GoogleTest
      run: (...)
    
    # This step fails, see error log below
    - name: Configure
      run: |
        mkdir build
        cd build
        cmake ..

Error log:

Run mkdir build
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Scanning dependencies of target common-populate
[ 11%] Creating directories for 'common-populate'
[ 22%] Performing download step (git clone) for 'common-populate'
-- Configuring incomplete, errors occurred!
See also "/home/runner/work/queue/queue/build/CMakeFiles/CMakeOutput.log".
Cloning into 'common-src'...
fatal: could not read Username for 'https://github.com': No such device or address
Cloning into 'common-src'...
fatal: could not read Username for 'https://github.com': No such device or address
Cloning into 'common-src'...
fatal: could not read Username for 'https://github.com': No such device or address
-- Had to git clone more than once:
          3 times.
CMake Error at common-subbuild/common-populate-prefix/tmp/common-populate-gitclone.cmake:31 (message):
  Failed to clone repository: 'https://github.com/ORGANIZATION_NAME/common'


make[2]: *** [CMakeFiles/common-populate.dir/build.make:115: common-populate-prefix/src/common-populate-stamp/common-populate-download] Error 1
make[1]: *** [CMakeFiles/Makefile2:95: CMakeFiles/common-populate.dir/all] Error 2
make: *** [Makefile:103: all] Error 2

CMake Error at /usr/local/share/cmake-3.19/Modules/FetchContent.cmake:989 (message):
  Build step for common failed: 2
Call Stack (most recent call first):
  /usr/local/share/cmake-3.19/Modules/FetchContent.cmake:1118:EVAL:2 (__FetchContent_directPopulate)
  /usr/local/share/cmake-3.19/Modules/FetchContent.cmake:1118 (cmake_language)
  /usr/local/share/cmake-3.19/Modules/FetchContent.cmake:1161 (FetchContent_Populate)
  CMakeLists.txt:11 (FetchContent_MakeAvailable)


Error: Process completed with exit code 1.

How can we fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions