# \`ansible-builder\` ERROR when scm/git sourced content is in \`requirements.yml\`

**URL:** <https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387>\
**Category:** Get Help\
**Tags:** collections, ansible-builder, ee, galaxy-ng\
**Created:** [January 18, 2024, 6:57pm UTC](https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387 "2024-01-18T18:57:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![toast](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@toast](https://forum.ansible.com/u/toast)\
**Post date:** [January 18, 2024, 6:57pm UTC](https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387/1 "2024-01-18T18:57:49Z")

</div>

# Post

I am having some trouble trying to utilize a local/custom(non-galaxy) collection with ansible-builder. I’ve had no problem using ansible-builder until I started looking at packing in some newer collections we’ve developed internally.

The following requirements file is what I am currently trying to use. There are examples of https and git(ssh) methods for installing the collection in question. This requirements file has no problem working on the ansible-galaxy command line via `ansible-galaxy install -r requirements.yaml` or `ansible-galaxy collection install -r requirements.yaml`

My `requirements.yaml` file

```yaml
---
roles:
collections:
  - ansible.posix
  - ansible.utils
  - community.general
  - community.docker
  - community.network
  # This works with ansible galaxy 
  #- name: git@gitlab.flyingtoaster.dev:ansible_collections/flyingtoaster.docker.git
  # type: git
  # version: develop
  # This works with ansible galaxy 
  - name: https://gitlab.flyingtoaster.dev/ansible_collections/flyingtoaster.docker.git
    type: git
    version: develop
...

```

`ansible-builder build` command output:

```bash
Running command:
  docker build -f context/Dockerfile -t toast/flyingtoaster-ee context
...showing last 20 lines of output...
#17 [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install --pre -r requirements.yml --collections-path "/usr/share/ansible/collections"
#17 12.36 ERROR! Could not find git executable to extract the collection from the Git repository `https://gitlab.flyingtoaster.dev/ansible_collections/flyingtoaster.docker.git`.
#17 12.36 Starting galaxy collection install process
#17 12.36 Process install dependency map
#17 ERROR: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 1
------
 > [galaxy 5/5] RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install --pre -r requirements.yml --collections-path "/usr/share/ansible/collections":
12.36 ERROR! Could not find git executable to extract the collection from the Git repository `https://gitlab.flyingtoaster.dev/ansible_collections/flyingtoaster.docker.git`.
12.36 Starting galaxy collection install process
12.36 Process install dependency map
------
Dockerfile:43
--------------------
  41 |
  42 | RUN ansible-galaxy role install $ANSIBLE_GALAXY_CLI_ROLE_OPTS -r requirements.yml --roles-path "/usr/share/ansible/roles"
  43 | >>> RUN ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path "/usr/share/ansible/collections"
  44 |
  45 | # Builder build stage
--------------------
ERROR: failed to solve: process "/bin/sh -c ANSIBLE_GALAXY_DISABLE_GPG_VERIFY=1 ansible-galaxy collection install $ANSIBLE_GALAXY_CLI_COLLECTION_OPTS -r requirements.yml --collections-path \"/usr/share/ansible/collections\"" did not complete successfully: exit code: 1

An error occurred (rc=1), see output line(s) above for details.

```

I’ve struggled to find any documentation around using custom scm/git repos in the requirements file specifically for ansible-builder. However seeing as this works just fine with the ansible-galaxy command line as documented, I struggle to understand where the hangup is. Also to be clear, the `ansible-builder` command works as expected without any error when the internal git/scm item is removed from/commented out in the requirements file.

I greatly appreciate any assistance or pointing in the right direction that anyone can provide.

Thank you!

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [January 19, 2024, 4:34am UTC](https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387/2 "2024-01-19T04:34:25Z")

</div>

Hi, I think this error message is the answer.

> ```auto
> 12.36 ERROR! Could not find git executable to extract the collection from the Git repository `https://gitlab.flyingtoaster.dev/ansible_collections/flyingtoaster.docker.git`.
> 
> ```

I mean, the image you’ve specified as `base_image` does not contain `git` command.

As a quick workaround, append `additional_build_steps` to your `execution-environment.yml` file. This installs `git-core` just before `ansible-galaxy` command invokation.

```yaml
additional_build_steps:
  prepend_galaxy:
    - RUN $PKGMGR install git-core -y; if [-z $PKGMGR_PRESERVE_CACHE]; then $PKGMGR clean all; fi

```

Note that Ansible Builder has ability to install system packages using `bindep` through `dependencies.system` in `execution-environment.yml` and `git-core` can be installed via `bindep`, but `bindep` will be invoked AFTER `ansible-galaxy`, so in your case `bindep` can not help you.

Hope this helps.

---

<div class="post-metadata">

**Author:** ![toast](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@toast](https://forum.ansible.com/u/toast)\
**Post date:** [January 21, 2024, 12:56am UTC](https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387/3 "2024-01-21T00:56:26Z")

</div>

Thank you, thank you, THANK YOU!

I can’t tell you how many cycles I wasted on that error. A clear problem of tunnel vision/spending too much time on a problem and needing a fresh set of eyes. You’re absolutely correct my problem was in fact the lack of a git executable in the image itself and not the git repo.

I’m most thankful for your suggested additions to my build file, you certainly pointed me in the right direction.

I know I’m a random person on the internet, but you really made a difference with whatever time and energy you put into this reply, so again, thank you!

---

<div class="post-metadata">

**Author:** ![kurokobo](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kurokobo/32/182_2.png) [@kurokobo](https://forum.ansible.com/u/kurokobo)\
**Post date:** [January 21, 2024, 5:35am UTC](https://forum.ansible.com/t/ansible-builder-error-when-scm-git-sourced-content-is-in-requirements-yml/3387/4 "2024-01-21T05:35:41Z")

</div>

I’m glad it seems to be solved, it is unusual to receive such a polite and heartwarming reply, thank you 😊

In fact, for the users who have faced some problems, the first step to getting enough answers from the community is providing enough information. However it is not easy to organize the situation and describe it clearly to others.  
In this sense, I was able to help you because YOU definitely provided enough information for us to understand your situation clearly and correctly.  
That is, the goals you want to achieve, the problems you faced, your thought, the tries you made and its results, the actual files and the actual logs.

This topic you have created will help someone else in the future who has faced the same problem. So I would also want to say thank you for your great job and contribution!
