# Molecule error started happening for role dependency

**URL:** <https://forum.ansible.com/t/molecule-error-started-happening-for-role-dependency/2449>\
**Category:** Get Help\
**Tags:** molecule, galaxy-ng\
**Created:** [November 18, 2023, 1:38pm UTC](https://forum.ansible.com/t/molecule-error-started-happening-for-role-dependency/2449 "2023-11-18T13:38:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![staticdev](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/staticdev/32/1582_2.png) [@staticdev](https://forum.ansible.com/u/staticdev)\
**Post date:** [November 18, 2023, 1:38pm UTC](https://forum.ansible.com/t/molecule-error-started-happening-for-role-dependency/2449/1 "2023-11-18T13:38:39Z")

</div>

I have a [repo of an ansible role](https://github.com/staticdev/ansible-role-python-developer) tested with molecule for some years now. Without a real change, my tests started failing on August 2023 when I import my role due to its dependencies on `meta/main.yml`.

For some reason I get the error:

```auto
  TASK [Include staticdev.python_developer] **************************************
  ERROR! the role 'staticdev.pyenv' was not found in ansible.legacy:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/molecule/default/roles:/home/runner/.cache/molecule/staticdev.python_developer/default/roles:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer:/home/runner/.ansible/roles:/usr/share/ansible/roles:/etc/ansible/roles:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer:/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/molecule/default
  
  The error appears to be in '/home/runner/work/ansible-role-python-developer/ansible-role-python-developer/staticdev.python_developer/meta/main.yml': line 37, column 5, but may
  be elsewhere in the file depending on the exact syntax problem.
  
  The offending line appears to be:
  
  dependencies:
    - name: staticdev.pyenv
      ^ here

```

The role exists on Ansible Galaxy with correct version. **This error only happens on Github Actions** , but not locally. I do not really understand why, but on my path locally molecule can find `staticdev.pyenv` and can import statically. Do I need to add anything extra to install the requirements?

I tried found a change in the docs for syntax of `role-file` to `requirements-file`, but both syntaxes give the same failure:

```yaml
dependency:
  name: galaxy
  options:
    requirements-file: requirements.yml

```

Does anyone has an idea?

---

<div class="post-metadata">

**Author:** ![atul\_mohan](https://avatars.discourse-cdn.com/v4/letter/a/f04885/32.png) [@atul\_mohan](https://forum.ansible.com/u/atul_mohan)\
**Post date:** [December 29, 2024, 3:56am UTC](https://forum.ansible.com/t/molecule-error-started-happening-for-role-dependency/2449/2 "2024-12-29T03:56:59Z")

</div>

### **A. `requirements.yml`**

```auto
---
roles:
  - src: https://galaxy.ansible.com/staticdev/pyenv
    name: staticdev.pyenv
    version: "2.0.0" # Replace with the desired version

```

### **B. `molecule/default/molecule.yml`**

```auto
---
dependency:
  name: galaxy
  options:
    role-file: ../../requirements.yml # Adjust the relative path based on your project structure
    ignore-errors: false
driver:
  name: docker
platforms:
  - name: instance
    image: geerlingguy/docker-ubuntu1804-ansible:latest # Use an appropriate base image
    pre_build_image: false
    volumes:
      - /sys/fs/cgroup:/sys/fs/cgroup:ro
    privileged: true
provisioner:
  name: ansible
  lint:
    name: ansible-lint
scenario:
  name: default
verifier:
  name: ansible

```

### **C. `.github/workflows/molecule.yml`**

```auto
name: Molecule Tests

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.8' # Specify the Python version compatible with your project

      - name: Install Ansible
        run: |
          python -m pip install --upgrade pip
          pip install ansible

      - name: Install Molecule and Docker
        run: |
          pip install molecule[docker] docker

      - name: Install Role Dependencies
        run: |
          ansible-galaxy install -r requirements.yml

      - name: Run Molecule Tests
        run: |
          molecule test

```

### **D. `meta/main.yml`**

```auto
---
galaxy_info:
  author: Your Name
  description: Your role description
  company: Your Company
  license: license (e.g., MIT)

dependencies:
  - role: staticdev.pyenv
    version: "2.0.0" # Ensure this matches the version in requirements.yml

```
