Dove a little deeper, tried running just pip install -r requirements.txt
which executes successfully.
Then tried trellis init
, it failed again. Tried to deploy, got:
ERROR! Unexpected Exception, this is probably a bug: cannot import name 'AnsibleCollectionLoader' from 'ansible.utils.collection_loader' (/home/username/.local/lib/python3.10/site-packages/ansible/utils/collection_loader/__init__.py)
So somewhere in the mix, the unsupported python version is still acting up.
I checked python binaries from within the project:
which python
/home/blackthorne/work/thethirdwave.co/trellis/.trellis/virtualenv/bin/python
❯ which python3
/home/blackthorne/work/thethirdwave.co/trellis/.trellis/virtualenv/bin/python3
❯ python --version
Python 3.9.13
❯ python3 --version
Python 3.9.13
All good there. Then checked from outside the project folder:
/usr/bin/python
❯ which python3
/home/linuxbrew/.linuxbrew/bin/python3
❯ python --version
Python 3.10.4
❯ python3 --version
Python 3.9.13
Well, crap. the regular python command is installed as a dependency of my system packages, I worry that downgrading it will break my system, and, I don’t understand why it’s being utilized in the first place. Shouldn’t the virtualenv install of Python be used in this case? Is this a trellis-cli bug?
UPDATE:
Tried running ansible-playbook deploy.yml -vvvv -e "site=example.com env=staging"
, I still get the same ansible error referencing python 3.10. Downgrading this is likely to break my other software dependencies, so I feel a biiiiit stuck.
UPDATE 2:
Tried copying over the .trellis folder with the correct dependencies installed from my laptop computer. Upon running a trellis deploy
command, my error message is now:
fork/exec /home/username/work/example.com/trellis/.trellis/virtualenv/bin/ansible-playbook: permission denied
, which is reminescent of the trellis-cli error with the trellis exec pip install -r requirements.txt
command suggested above.
UPDATE 3: I also installed pyenv and used it to install python 3.9.13, and set it locally using pyenv local 3.9.13
in the trellis folder. I checked:
3.9.13 (set by /home/username/work/example.com/trellis/.python-version)
No change in terms of behavior.
UPDATE 4: I got a bit more creative, navigated to /home/linunxbrew/.linuxbrew/bin , ran pyenv local 3.9.13
and successfully created a new trellis project using trellis new
in that folder.
Trying to execute something similar elsewhere, including by going to my projects folder(s) and running pyenv exec trellis init
, for example, still fails.
@swalkinshaw I still can’t tell if this is a bug in trellis-cli or not. It doesn’t help that running ansible-playbook
directly, in the project folder, with pyenv local 3.9.13
set, still uses the system-installed Python 3.10, which points to the answer being not, but without any insight into why trellis obeys the pyenv restriction from within the folder its binary is located in, but not outside of that folder.