Skip to content
DevOps AI ToolKit
All guides
AI for Ansible By James Joyner IV · · 6 min read Last reviewed Jul 2026

Ansible Error: 'Failed to find required executable git in paths' — Cause, Fix, and Troubleshooting Guide

Quick answer

Fix Ansible git module 'Failed to find required executable git in paths' error: install git on the target or fix PATH for the become user.

  • #ansible
  • #troubleshooting
  • #automation
  • #modules
Free toolkit

Stuck on this Ansible error? Get the free incident triage checklist

A one-page PDF — the exact steps to isolate, fix, and verify a production error like this one. No spam, unsubscribe anytime.

Overview

Several modules shell out to an external binary on the target host — the git module needs git, unarchive needs tar/unzip, pip needs pip. When the binary is not installed or not on the resolved PATH, the module fails:

fatal: [web-01]: FAILED! => {"changed": false, "msg": "Failed to find required executable \"git\" in paths: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"}

The message lists the exact PATH that was searched, which is the key diagnostic.

Symptoms

  • The git (or pip, svn, make) task fails on a minimal host.
  • git is installed but only found in an interactive shell, not under Ansible.
  • Works for one user but fails when running as a different become_user.
ansible web-01 -i inventory.ini -b -m git -a 'repo=https://github.com/acme/app.git dest=/opt/app'
web-01 | FAILED! => {"msg": "Failed to find required executable \"git\" in paths: /usr/bin:/bin"}

Common Root Causes

1. git is simply not installed

The most common case on slim base images and containers.

2. Installed outside the searched PATH

git lives in /usr/local/bin or /opt/.../bin, but Ansible’s non-login shell PATH does not include it.

3. PATH differs for the become user

root’s or the service user’s PATH is narrower than your interactive login shell’s.

4. Package name mismatch

Installing the wrong package name for the distro (git-core vs git).

How to diagnose

Check whether the binary exists and where:

ansible web-01 -i inventory.ini -b -m shell -a 'command -v git; echo "PATH=$PATH"'

Compare interactive vs non-interactive PATH:

ansible web-01 -i inventory.ini -b -m shell -a 'bash -lc "command -v git"'

Fixes

Install git before the git task

- name: Ensure git is installed
  ansible.builtin.package:
    name: git
    state: present

- name: Clone the app repo
  ansible.builtin.git:
    repo: https://github.com/acme/app.git
    dest: /opt/app
    version: main

Point the module at the binary’s real location

Set PATH for the task’s environment:

- name: Clone with extended PATH
  ansible.builtin.git:
    repo: https://github.com/acme/app.git
    dest: /opt/app
  environment:
    PATH: "/usr/local/bin:{{ ansible_env.PATH }}"
ansible web-01 -i inventory.ini -b -m file -a "src=/opt/tools/bin/git dest=/usr/local/bin/git state=link"

What to watch out for

  • Ansible uses a non-login shell, so ~/.bashrc/~/.profile PATH tweaks do not apply — set PATH via the module’s environment or install to a standard location.
  • Order dependencies explicitly: the install task must run before the module that needs the binary.
  • The PATH: value in the error is exactly what was searched — compare it against command -v git on the host to pinpoint the gap.
Free download · 368-page PDF

Fixed it? Get 500 Ansible & DevOps AI prompts — free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.

Stuck on this? Start guided troubleshooting

Open an interactive diagnostic session with this error already loaded. Work a step-by-step plan, record what each check returns, land on a root cause, and export a clean incident summary — no account needed to start.

Did this fix your issue?

Solved it a different way?

Share the fix that worked for you — reviewed, then published to help the next engineer.

Free download · 368-page PDF

Get 500 Battle-Tested DevOps AI Prompts — Free

500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.

  • 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
  • Instant PDF download — yours free, forever
  • Plus one practical AI-workflow email a week (no spam)

Single opt-in · unsubscribe anytime · no spam.