mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
14.01k stars 1.44k forks source link

Python rtyaml Module Missing #2421

Open MSSEsq opened 3 months ago

MSSEsq commented 3 months ago

It seems that a recent upgrade, possibly of Python 3.10 or Duplicity, removed Josh’s rtyaml Python module https://pypi.org/project/rtyaml/. This prevents proper execution of backup.py, dns_update.py, management.sh, utils.py, and web_update.py. To confirm that the rtyaml module is missing, run pip list which will list all installed Python modules. It seems likely that the missing rtyaml module is the underlying cause of problem #2420.

JoshData commented 3 months ago

It's installed explicitly into a virtualenv at https://github.com/mail-in-a-box/mailinabox/blob/162e509b8bf0683a70cf92fb8b7623c0dba5d051/setup/management.sh#L46 so running mailinabox should fix it. But in that issue, the backup command is invoked the wrong way, which probably explains the problem.

kiekerjan commented 3 months ago

In this case you should run /usr/local/lib/mailinabox/env/bin/pip list That will use the mailinabox virtual environment

MSSEsq commented 3 months ago

I had previously run curl -s https://mailinabox.email/setup.sh | sudo bash and now ran mailinabox as Josh suggested. Neither fixed the problem of the rtyaml module not being found. Running cd /root/mailinabox/management then python3 backup.py still returns ModuleNotFoundError: No module named 'rtyaml'. Nevertheless, running /usr/local/lib/mailinabox/env/bin/pip list confirms that the rtyaml module is installed in the virtualenv. For some reason, the rtyaml module in the virtualenv is not being found.

JoshData commented 3 months ago

Don't put python3 in the command to start backup.py. Just give the path to the python script alone. It has a shebang line at the top to activate its virtualenv where its packages are installed.

MSSEsq commented 3 months ago

I originally tried directly running backup.py in the management directory without the python3 command which returns backup.py: command not found even though running ls confirms that the backup.py file is in the management directory. The only command line I tried that works properly is ~/mailinabox/management# /usr/local/lib/mailinabox/env/bin/python3 backup.py which seems to indicate that the virtualenv is not being used unless the full path to python3 in the virtualenv is specified.

amedee commented 3 months ago

Did you run backup.py or ./backup.py? The ./ makes a big difference! If you don't give your shell a path to find a command, it will first look at al the directories in the $PATH variable, and if it doesn't find a command there, it will give up with command not found.

MSSEsq commented 3 months ago

I did run backup.py which failed. Running ./backup.py which specifies running from the current directory rather than the command search path does enable the shebang line in backup.py to direct running python3 from the virtualenv. Thanks for the suggestion. I should have realized that the MiaB management directory is not in the default system command search path.

amedee commented 3 months ago

Could be a nice improvement, to add the MiaB management directory to the command search path. I'm going to make that customization.

MSSEsq commented 3 months ago

I had the same thought about appending the MiaB management directory to the command search path. I created a file named “Mail-in-a-Box_management.sh” owned by 0:0 with mode 644 and saved it to the /etc/profile.d directory. This file contains:

# If a Mail-in-a-Box management directory exists # then append it to the commamnd search path. if [ -d "/root/mailinabox/management" ] ; then PATH="$PATH:/root/mailinabox/management" fi

This customization should be harmless because the default search path retains priority and no change is made to the search path unless the MiaB management directory exists. For an informative discussion of the ways to change the command search path see: https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile

amedee commented 2 months ago

I had the same thought about appending the MiaB management directory to the command search path. I created a file named “Mail-in-a-Box_management.sh” owned by 0:0 with mode 644 and saved it to the /etc/profile.d directory. This file contains:

If a Mail-in-a-Box management directory exists

then append it to the commamnd search path.

if [ -d "/root/mailinabox/management" ] ; then PATH="$PATH:/root/mailinabox/management" fi

This customization should be harmless because the default search path retains priority and no change is made to the search path unless the MiaB management directory exists. For an informative discussion of the ways to change the command search path see: https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile

I applied it as such on my box using Ansible.