Ansible-dev-environment fails in container

I created a new collection using the VSCode Ansible extension “New collection project” functionality. As part of the collection project creation a devcontainer configuration was created (yay), but when trying to use the devcontrainer I get the below errors from ade.

$ ade install -e .
   Error: Collections found in /usr/share/ansible/collections
    Hint: Run `sudo rm -rf /usr/share/ansible/collections` to remove them.
   Error: Unable to use user site packages directory: /root/.local/lib/python3.13/site-packages, please activate or specify a
          virtual environment
    Hint: Use `--venv <directory>` to specify a virtual environment or enable an existing one.
Critical: The development environment is not isolated, please resolve the above errors.

ansible-galaxy shows that there are collections installed:

$ ansible-galaxy collection list

# /usr/share/ansible/collections/ansible_collections
Collection        Version
----------------- -------
ansible.netcommon 7.1.0  
ansible.posix     2.0.0  
ansible.scm       3.0.0  
ansible.utils     5.1.2  

The container image that is specified in the .devcontainer/podman/devcontainer.json file is ghcr.io/ansible/community-ansible-dev-tools:latest.

Is this ade designed to be able to work inside a devcontainer? Is there a different community image that doesn’t contain any pre-installed collections or do I need to build my own image?

Did you ever find the answer to this, Brant? I just ran into the same thing, and have the same questions. :slight_smile:

There’s no reason why ADE shouldn’t work inside a devcontainer; AFAIK.

You could add a PostCreateCommand to the devcontainer.json file to delete the collections path in preparation for running ADE, or as you said already, build your own image.

That’s a good idea, but I still think the default container image that is used shouldn’t have any pre-installed collections as it prevents ADE from working OOTB.

1 Like

Oh I agree with you. It should work OOTB. :slightly_smiling_face: