samschott / maestral

Open-source Dropbox client for macOS and Linux
https://maestral.app
MIT License
3.12k stars 64 forks source link

Autostart does not work in virtualenviroment on Kubuntu 23.04 #904

Closed samschott closed 1 year ago

samschott commented 1 year ago
          I have the same problem, but with virtualenviroment on Kubuntu 23.04:

maestral doesn't autostart. I have to source maestral-venv/bin/activate to be able to start maestral.

ralf@ralf-Aspire-1810TZ:~$ maestral
Traceback (most recent call last):
  File "/home/ralf/.local/bin/maestral", line 5, in <module>
    from maestral.cli import main
ModuleNotFoundError: No module named 'maestral'
ralf@ralf-Aspire-1810TZ:~$ source maestral-venv/bin/activate
(maestral-venv) ralf@ralf-Aspire-1810TZ:~$ maestral gui

then maestral works until I close the console-window. How can I have maestral gui autostart again?

btw: I needed to enable system-site-packages to activate dbus in venv. Without it, maestral didn't work. python3 -m venv --system-site-packages maestral-venv

Thanks in advance

PS: If you think, that this is worth a separate Issue, please split it.

Originally posted by @walterheisenberg in https://github.com/samschott/maestral/issues/847#issuecomment-1544634317

samschott commented 1 year ago

I'm not sure what you mean by autostart. If you refer to the systemd integration to start Maestral automatically on login, this should work perfectly fine even with a venv setup.

If you simply want to use the CLI commands without activating the venv, you can either run maestral-venv/bin/maestral directly or create a symlink for this location somewhere on your PATH.

walterheisenberg commented 1 year ago

here is a log before doing: python3 -m venv --system-site-packages maestral-venv https://pastebin.com/dpmNjEbk

With "autostart" I ment "starting the maestral daemon after login as described in "--help":

autostart Automatically start the sync daemon on login.

This doesn't work. I tried (in venv) ofc:

maestral autostart
Autostart is enabled. Use -N to disable.

maestral (with gui) was installed on the Kubuntu version before (22.10) and worked with "autostart" (after login). Then I upgraded to 23.04 and mestral stopped working. As a solution I used the "venv"-method from the "Installation guide". On my other PC with Kubuntu 23.04 I used python3 -m pip install --upgrade maestral --break-system-packages and everything worked as before in Kubuntu 22.10 (see https://github.com/samschott/maestral/issues/886#issuecomment-1519057618) In both cases it was a system-upgrade from 22.10 to 23.04, no fresh installation.

I checked "autostart":

ralf@ralf-Aspire-1810TZ:~$ cd .config/autostart/
ralf@ralf-Aspire-1810TZ:~/.config/autostart$ ls -l
insgesamt 8
-rw-rw-r-- 1 ralf ralf 309 Jul 17  2022 dropbox.desktop
-rwxrw-r-- 1 ralf ralf 208 Sep  2  2022 maestral-maestral.desktop
ralf@ralf-Aspire-1810TZ:~/.config/autostart$ cat maestral-maestral.desktop 
[Desktop Entry]
Version=1.0
Type=Application
Name=Maestral
Exec=/usr/bin/python3 -m maestral_qt -c maestral
Icon=maestral
X-GNOME-Autostart-enabled=true
X-GNOME-Autostart-Delay=2
X-KDE-autostart-after=panel

This is IMHO the wrong entry for the "new" venv. After deleting it via Kubuntu-GUI (Plasma) there is no entry for maestral, even after doing "maestral autostart" again. Thx for help

samschott commented 1 year ago

Indeed, it looks like the XDG desktop entry uses a command /usr/bin/python3 -m maestral_qt -c maestral which no longer works when Maestral is installed in a venv. I'll need to fix that.

On a related note, the checkbox "Start on login" in the GUI (which created the file that you've quoted above) results in the GUI automatically starting on login. The maestral autostart -Y|-N command however is specific to the daemon only. This command incidentally still works, it uses slightly different logic which still works in virtual environments.

In the meantime, you can manually edit the XDG file to replace:

"/usr/bin/python3 -m maestral_qt -c maestral" -> "HOME/maestral-venv/bin/maestral_qt"
samschott commented 1 year ago

... where you replace HOME with the actual parent folder of the venv directory.