Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.32k stars 9.72k forks source link

Can't access private git repositories inside brew formula #10705

Closed danieleformichelli closed 3 years ago

danieleformichelli commented 3 years ago

brew config output

HOMEBREW_VERSION: 3.0.2-52-g38be286 ORIGIN: https://github.com/Homebrew/brew HEAD: 38be2866435fb44ad796c5dc97532c190084b54d Last commit: 2 hours ago Core tap ORIGIN: https://github.com/Homebrew/homebrew-core Core tap HEAD: 94e2ea9ce8fc394918f3e00851faddf61e694dec Core tap last commit: 3 hours ago Core tap branch: master HOMEBREW_PREFIX: /usr/local HOMEBREW_CASK_OPTS: [] HOMEBREW_MAKE_JOBS: 8 Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby CPU: octa-core 64-bit kabylake Clang: 12.0 build 1200 Git: 2.30.1 => /usr/local/bin/git Curl: 7.64.1 => /usr/bin/curl macOS: 11.2.1-x86_64 CLT: N/A Xcode: 12.4

brew doctor output

Your system is ready to brew.


What were you trying to do (and why)?

We have a private brew tap git repository, with a formula which points to another private git repositories. The formula itself is a SwiftPackageManager and one of the dependencies is on yet another private git repositories

What happened (include all command output)?

The private brew repository and the "main" private git repository containing the sources is checked out correctly, but the command fails when it tries to resolve the internal private dependencies (which can be accessed with the same information with which the external one are accessed):

brew install privateRepo/aFormula
==> Cloning https://github.com/privateRepo
Updating /Users/df/Library/Caches/Homebrew/aFormula--git
==> Checking out tag 0.5.0-beta.1
Previous HEAD position was af79761 Merge pull request #96
HEAD is now at d3f5d87 Merge pull request #118
HEAD is now at d3f5d87 Merge pull request #118
error: Failed to clone https://github.com/dependentPrivateRepo:
    Cloning into bare repository '/private/tmp/aFormula-20210225-79303-bpd6cn/.build/repositories/dependentPrivateRepo-55d40119'...
    fatal: could not read Username for 'https://github.com': terminal prompts disabled
error: Failed to clone https://github.com/dependentPrivateRepo:
    Cloning into bare repository '/private/tmp/aFormula-20210225-79303-bpd6cn/.build/repositories/dependentPrivateRepo-55d40119'...
    fatal: could not read Username for 'https://github.com': terminal prompts disabled
Error: An exception occurred within a child process:
  Errno::ENOENT: No such file or directory - /private/tmp/aFormula-20210225-79303-bpd6cn/.build/x86_64-apple-macosx/release/aFormula

Note that the terminal prompts disabled error is because SwiftPackageManger disables automatically the terminal prompt, but even removing the SPM command and adding just a git clone, I get prompted for the git credentials, while the formula should access the system-configured ones.

Using ssh instead of https for the private git URL workarounds the problem.

What did you expect to happen?

The formula should be able to access the dependent private repository using the system-configured git credentials, as it does correctly for accessing the main private repository.

Step-by-step reproduction instructions (by running brew commands)

  1. Have locally configured git credential
  2. have a private formula that tries to checkout another private repository using HTTPS. For example:

    class AFormula < Formula
    desc "AFormula"
    homepage "https://github.com/aPrivateRepository"
    url "https://github.com/aPrivateRepository.git",
      tag:      "1.0.0",
      revision: "asdasdasdasdasdasdasdasdasdasdasdadsa"
    head "https://github.com/aPrivateRepository.git"
    
    def install
    git clone https://github.com/anotherPrivateRepository
    end
    end
  3. Try to install the formula brew install --build-from-source aFormula.rb
MikeMcQuaid commented 3 years ago

This is not supported functionality, sorry.