# Community.general.ansible\_galaxy\_install Not Using Correct PATH - But This May Not Be The Actual Problem

**URL:** <https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920>\
**Category:** Get Help\
**Tags:** galaxy-ng\
**Created:** [July 17, 2025, 11:12am UTC](https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920 "2025-07-17T11:12:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dulux-Oz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulux-oz/32/9047_2.png) [@Dulux-Oz](https://forum.ansible.com/u/Dulux-Oz)\
**Post date:** [July 17, 2025, 11:12am UTC](https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920/1 "2025-07-17T11:12:19Z")

</div>

Hi All,

Bare with me, please, this is slightly complex.

I’m trying to use `community.general.ansible_galaxy_install` inside a playbook to ensure that the remote host (which is an(other) Ansible Control Node (ACN)) has a number of Collections installed.

Both my current ACN and the remore ACN are Rocky Linux hosts. Rocky Linux does _not_ place `/usr/local/bin` into the default PATH (only `/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin`). Of course, where is `ansible-galaxy` (and the other `ansible*` tools) installed? That’s right, `/usr/local/bin`.

So, I’ve modified my systems’ `/etc/bashrc.d/ansible` file to add `/usr/local/bin` to the PATHs of the relevant users. This is working AOK.

However, in my playbook I’m receiving the following error:

```auto
failed: [host2.example.com] (item=ansible.posix) => {"ansible_loop_var": "item", "changed": false, "item": "ansible.posix", "msg": "Failed to find required executable \"ansible-galaxy\" in paths: /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin"}

```

This means that my `/etc/bashrc.d/ansible` file (or any of the Ansible User’s various `.bashrc`, `.bash_profile`, etc, files) are not being picked up when performing the various tasks on the remote host.

BUT when I ssh into the remote host from the CLI the correct PATH _is_ being correctly picked up.

So my questions are:

- What is the best way to ensure that when working on the remote host the PATH is correctly set to include `/usr/local/bin`?
- Is there some sort of Ansible Variable I should be setting?
- Is there some sort of `bashrc` (or other file) that I need to (further) modify?
- Is there some way of forcing the `community.general.ansible_galaxy_install` to include the “extra” PATH settings (I can’t find anything in the doco if it _is_ there)?
- Is there some other solution to my issue that I’ve overlooked? - which would not surprise me one bit; I’m still preety green in using Ansible.

Thanks in advance

Dulux-Oz

---

<div class="post-metadata">

**Author:** ![chris](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/chris/32/293_2.png) [@chris](https://forum.ansible.com/u/chris)\
**Post date:** [July 18, 2025, 7:21am UTC](https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920/2 "2025-07-18T07:21:02Z")

</div>

> [@Dulux-Oz](#):
>
> Is there some way of forcing the `community.general.ansible_galaxy_install` to include the “extra” PATH settings (I can’t find anything in the doco if it _is_ there)?

Yes, you can do this:

```yaml
- name: Ansible collection install 
  community.general.ansible_galaxy_install:
    name: foo.bar
    type: collection
  environment:
    PATH: /usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

```

---

<div class="post-metadata">

**Author:** ![Dulux-Oz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dulux-oz/32/9047_2.png) [@Dulux-Oz](https://forum.ansible.com/u/Dulux-Oz)\
**Post date:** [July 18, 2025, 7:44am UTC](https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920/3 "2025-07-18T07:44:40Z")

</div>

Thank you @chris, that did the trick. 😄

(Another factoid to add to my mostly-empty Ansible toolbox) 😁

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [August 17, 2025, 7:44am UTC](https://forum.ansible.com/t/community-general-ansible-galaxy-install-not-using-correct-path-but-this-may-not-be-the-actual-problem/43920/4 "2025-08-17T07:44:59Z")

</div>

Closed on August 17, 2025, 7:44am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
