Skip to content
Latchkey

Bundler "Bundler::GitError" Cloning a Git Gem in CI

Bundler shelled out to git to clone a git-sourced gem and the command failed. The usual causes are missing credentials for a private repo, no network access to the host, or git not being installed on the runner.

What this error means

bundle install fails with Bundler::GitError and a "git clone" / "git fetch" command that exited non-zero - authentication failed, host unreachable, or git not found. The git gem cannot be fetched.

bundler output
Bundler::GitError: Git error: command `git clone --no-checkout --quiet
https://github.com/example/private-gem.git ...` in directory ... has failed.

fatal: could not read Username for 'https://github.com': No such device or address

Common causes

No credentials for a private git repo

A private git-sourced gem needs authentication. Without a token configured, git cannot read the repo and the clone fails with an auth error.

git missing or host unreachable

A slim image without git installed, or a runner that cannot reach the git host (blocked egress), makes the clone command fail outright.

How to fix it

Provide credentials for the private repo

Configure a token so Bundler can authenticate the git clone.

Terminal
bundle config set --local https://github.com/ "${GITHUB_TOKEN}:x-oauth-basic"
bundle install

Ensure git is installed and the host is reachable

Terminal
# Debian/Ubuntu
apt-get update && apt-get install -y git
# confirm reachability
git ls-remote https://github.com/example/private-gem.git

How to prevent it

  • Configure git credentials for private gem sources up front in CI.
  • Bake git into runner images that install git-sourced gems.
  • Prefer a private gem server over git sources for internal gems where possible.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →