qiime info FileNotFoundError on 2024.10 amplicon Docker

I tried to force the CONDA_PREFIX in my Apptainer container, but it does not change the result (Application config dir is still /home/qiime/q2cli), but I think I found out why.

I checked the q2cli source code ( and found this: /opt/conda/envs/qiime2-amplicon-2024.10/lib/python3.10/site-packages/q2cli/utils.py)

def get_app_dir():
    import os
    conda_prefix = os.environ.get('CONDA_PREFIX')
    if conda_prefix is not None and os.access(conda_prefix, os.W_OK | os.X_OK):
        return os.path.join(conda_prefix, 'var', 'q2cli')
    else:
        import click
        return click.get_app_dir('q2cli', roaming=False)

If I understand correctly, the function is checking if $CONDA_PREFIX folder is writable with os.access(conda_prefix, os.W_OK | os.X_OK) and if it's not, it will fallback on /home/qiime/q2cli and if it does not exist, it will be created.

The problem here is that this function is called each time the get_app_dir function is executed (during qiime info for exemple), but in Apptainer, every folders are only writable at build time. After that, the container is frozen in read-only. In Docker, that is not the case, the image is static, but the container in itself is not read only and can be written at any time (so no problem in that case).

That would explain why I can launch qiime info during build (which display the correct folder /opt/conda/envs/qiime2-amplicon-2024.10/var/q2cli, but cannot do so during runtime since it's frozen and it fallback on /home/qiime/q2cli and then crash because it cannot create the directory since it's also read-only in Apptainer.

As a temporary fix, I copied the /opt/conda/envs/qiime2-amplicon-2024.10/var/q2cli to /home/qiime/q2cli, but I don't know if it could negatively affect qiime during runtime.

Do you have any inputs ?

As a possible solution, would it be possible to modify the get_app_dir functions (and other similar functions) to only check if a folder is writable when it need to be modify (if only read is needed, do a check if folder is accessible) ?

1 Like