I’m really just looking for some clarity here. I’m on a Mac with Monterey 12.1. I started using trellis-cli today and experienced this:
I ran trellis deploy staging
and it worked as expected. But I saw the warning
WARNING: no virtualenv found for this project. Trellis may not work as expected.
So I ran trellis init
and it created the .virtualenv folder. But now when I run trellis
commands, I get errors like this (even though the symlink and its target exist):
Error running ansible-playbook: fork/exec .../trellis/.trellis/virtualenv/bin/ansible-playbook: no such file or directory
I ran trellis check
and received this:
[X] Python [>= 2.7.0]:
[✓] Vagrant [>= 2.1.0]: 2.2.18
[✓] VirtualBox [>= 4.3.10]: 6.1.28r147628
So right now I’m wondering:
- Is this even a python issue or am I missing something?
- Isn’t the virtualenv folder supposed to eliminate the need for me to have specific versions of software installed? Especially since it contains a link to python3?
- Is the virtualenv folder really critical, especially since in my case, trellis-cli works without it?
- Any other thoughts or insight anyone is willing to share?
Those are all good questions.
Is this even a python issue or am I missing something?
I’m not exactly sure yet. Can you run ls -l trellis/.trellis/virtualenv/bin/
and show the output? Can you also run trellis which python
and trellis exec python --version
?
Isn’t the virtualenv folder supposed to eliminate the need for me to have specific versions of software install? Especially since it contains a link to python3?
You still need to install Python 3 yourself, but otherwise yes. The benefit of virtualenv is a self-contained Python environment per Trellis project with the proper dependencies installed (mainly Ansible).
Is the virtualenv folder really critical, especially since in my case, trellis-cli works without it?
I’m assuming it was working prior to trellis init
because you had manually installed the proper ansible
version via pip
(or some other method). So no, the virtualenv isn’t strictly needed, but that warning was added because lots of people were adopting trellis-cli for existing projects but not running trellis init
.
It’s a bit confusing/unnecessary in a case like yours where you had things working properly. But assuming the virtualenv feature works properly, it should be the more stable method going forward.
Any other thoughts or insight anyone is willing to share?
As that warning mentioned, you can also just disable the automated check if everything is working fine for you.
Thanks so much for the prompt response, @swalkinshaw. I found this web page Python & Trellis but wasn’t crystal clear on what action I should take (if any). It sounded like I didn’t need to do anything, since I’m on a Mac and have both python and python3 installed? Would you recommend for the time being that I should not worry virtualenv?
trellis which python
didn’t work, but here’s the other two commands.
adam@Home-Office trellis % ls -l .trellis/virtualenv/bin/
total 192
-rw-r--r-- 1 adam staff 8834 Mar 1 14:56 Activate.ps1
-rw-r--r-- 1 adam staff 1964 Mar 1 14:56 activate
-rw-r--r-- 1 adam staff 913 Mar 1 14:56 activate.csh
-rw-r--r-- 1 adam staff 2053 Mar 1 14:56 activate.fish
-rwxr-xr-x 1 adam staff 6017 Mar 1 14:56 ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-config -> ansible
-rwxr-xr-x 1 adam staff 13516 Mar 1 14:56 ansible-connection
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-console -> ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-doc -> ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-galaxy -> ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-inventory -> ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-playbook -> ansible
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-pull -> ansible
-rwxr-xr-x 1 adam staff 872 Mar 1 14:56 ansible-test
lrwxr-xr-x 1 adam staff 7 Mar 1 14:56 ansible-vault -> ansible
-rwxr-xr-x 1 adam staff 335 Mar 1 14:56 pip
-rwxr-xr-x 1 adam staff 335 Mar 1 14:56 pip3
-rwxr-xr-x 1 adam staff 335 Mar 1 14:56 pip3.9
lrwxr-xr-x 1 adam staff 9 Mar 1 14:56 python -> python3.9
lrwxr-xr-x 1 adam staff 9 Mar 1 14:56 python3 -> python3.9
lrwxr-xr-x 1 adam staff 39 Mar 1 14:56 python3.9 -> /usr/local/opt/python@3.9/bin/python3.9
adam@Home-Office trellis % trellis exec python --version
Python 3.9.10
Oops sorry, I meant trellis exec which python
.
The surprising part here is that ansible-playbook
does exist in the virtualenv, but yet your error says it doesn’t 
Oh, does project path contain spaces in it anywhere? trellis new command fails when in directory with spaces and outputs project created · Issue #206 · roots/trellis-cli · GitHub shows a similar error to yours
Thanks, that command worked:
I think you figured it out. My path does have spaces. I just tested in a directory without spaces in the path (trellis new
and trellis dotenv
) and it worked without issue.
I guess that explains things for now?
adam@Home-Office trellis % trellis exec which python
/Volumes/Storage/(folders containing spaces)/trellis/.trellis/virtualenv/bin/python
3 Likes
It does, thanks. Going to mark this as a “solution” even though it just confirms the existing bug.
I just need to prioritize fixing that since people are running it more now (I thought it would be rarer).
1 Like
Update: v1.6.0 is out which supports spaces in paths
1 Like