Problem with bench init on Debian 12


Probably doing something wrong…
Fresh Debian 12 install, and just to make things complicated:

  1. Installed Docker and run HomeAssistant.
  2. Installed snapd and ran NextCloud instans (on port 81).

During Frappe install had a small issue with installing MariaDB, because apt did not know how to stop mysql, so I helped it:
snap stop nextcloud
Then got an error from pip when tried to install frappe-bench:

lon@debian:~$ sudo pip3 install frappe-bench
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

(I know I am using python 3.11, but it worked thus far so… )
Managed to fix it with:

alon@debian:~$ python3 -m venv venv
alon@debian:~$ source venv/bin/activate

However(!), after setting up my site and installing all apps, as soon as I tried to do a:

sudo bench setup production [frappe-user]

So the system will be running as production I get a None return from'nginx')) (or something similar, that runs during the procedure (sorry, I closed it).
the weird thing is that when I do:

alon@debian:~$ which nginx

I get nothing…

check if there a listener
ss -anltp
or netstat (I think the same switches work)

Well, something is listening on port 80:

alon@debian:~$ ss -anltp
State             Recv-Q            Send-Q                         Local Address:Port                         Peer Address:Port            Process            
LISTEN            0                 80                                           *                                  
LISTEN            0                 511                                          *                                  
LISTEN            0                 511                                              *                                  
LISTEN            0                 128                                              *                                  
LISTEN            0                 511                                    [::1]:6379                                 [::]:*                                  
LISTEN            0                 511                                     [::]:80                                   [::]:*                                  
LISTEN            0                 511                                        *:81                                      *:*                                  
LISTEN            0                 128                                     [::]:22                                   [::]:*                                  

I am not sure what or to to check this.

Solved it!
for running:
sudo bench setup production $USER command I wrote a small sh script that does:

source /home/alon/venv/activate
bench setup production alon

and run it as root after su ing into root shell.
Then, I did a symlink:

ln -s /usr/sbin/nginx /home/alon/venv/bin/nginx

and it did the trick wonderfully :slight_smile:
The only thing now is to do all this again (I am working on a virtual machine for testing) because my NextCloud installation doesn’t respond, so I probebly over-tinkered with things.
I’ll update ASAP.

1 Like

This works.