0

Has anybody faced with such a issue while trying to get private repository via FetchContent?

CMakeLists.txt:

include(FetchContent)

FetchContent_Declare(
    {repository}
    GIT_REPOSITORY https://{username}@github.com/{company}/{repository}
    USES_TERMINAL_DOWNLOAD ON
)

FetchContent_GetProperties({repository})
if(NOT {repository}_POPULATED)
    FetchContent_Populate({repository})
endif()

Output:

MSBuild version 17.3.1+2badb37d1 for .NET Framework
  Performing download step (git clone) for '{repository}-populate'
  Cloning into '{repository}-src'...
  bash: line 1: /dev/tty: No such device or address
CUSTOMBUILD : error : failed to execute prompt script (exit code 1) [C:\git\.....vcxproj]
  fatal: could not read Password for 'https://{username}@github.com': No such file or directory

 ...

  -- Had to git clone more than once: 3 times.
  CMake Error at {repository}-subbuild/{repository}-populate-prefix/tmp/{repository}-populate-gitclone.cmake:39 (message):
    Failed to clone repository: 'https://{username}@github.com/{company}/{repository}'

...

-- Configuring incomplete, errors occurred!
lfk
  • 57
  • 7
  • Disclaimer: I don't use cmake. The documentation is [here](https://cmake.org/cmake/help/latest/module/FetchContent.html). From what I can find, cmake simply runs your own existing Git installation, so to use a private repository, you do whatever it takes so that Git can clone your private repository without requiring feeding it a password. That means setting up an https credential helper (if using https) or ssh public key (if using ssh). – torek Sep 21 '22 at 02:35

1 Answers1

0
git config --global credential.helper store

works well (requires stored personal access token (PAT) - you could set it while cloning the repo for example)

lfk
  • 57
  • 7