samschott / maestral

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

CLI hangs indefintiely and linking fails after entering auth code from Dropbox on Raspbian 12 #1005

Open scrivener opened 11 months ago

scrivener commented 11 months ago

Describe the bug This bug occurs on a Raspberry Pi running Raspbian 12. I'm encountering it both on an install inside of a venv and on an install using --break-system-packages, both with --user and without --user.

When attempting to authenticate using auth link or start from the CLI, when I paste the auth code back into the CLI prompt (? Enter the auth code:) and press enter, the code turns grey and the CLI hangs indefinitely without any output or message. I've allowed it to sit overnight (~12 hours) and it does nothing. After ctrl-Cing out of the hang, my account isn't linked, and maestral seems to be in a bit of an incoherent authentication state:

To Reproduce

  1. Install maestral on a Raspberry Pi running Raspbian 12 using pip install --user --break-system-packages maestral, sudo pip install -break-system-packages maestral, or by creating a virtual environment and installing it in the venv with pip install maestral
  2. maestral auth link or maestral start
  3. When asked ? How would you like to you link your account?, select Print auth URL to console
  4. Copy auth URL and put it in the browser
  5. Click "Allow"
  6. Copy the code
  7. Paste it at the CLI's prompt asking ? Enter the auth code: and press enter.

Expected behaviour My Dropbox account should be linked. (Or at least I should get an error message saying what went wrong)

System:

Note that I'm not using the GUI at all and didn't install it with the GUI enabled. Haven't tried the option for opening the auth link in the browser, since the machine is headless.

Additional context I'm occasionally encountering something similar to #967, where something looking like ANSI escape codes (e.g., ^[[48;24R) get printed out in the middle of doing something else with the CLI (e.g., one of the commands above), which locks up the CLI and forces me to ctrl-C out. This happens seemingly at random, though it maybe happens more on a new configuration or fresh install? It happened only occasionally on the --user and venv installs, but I had a streak of it happening on every command for like 5-6 commands in a row on my non --user global install attempt.

scrivener commented 11 months ago

Update: Even though the machine is headless, Raspbian does have a GUI desktop running, so I set up XRDP to see if that would help. Authing through CLI in remote desktop shows a popup window for choosing a password for a new keyring to store credentials in. When I completed that popup, it worked and linked just fine. So I'm assuming the problem I was encountering above is that it is trying to do that keyring setup flow, but it can't. (I did try doing the steps above with a remote desktop session open, and it does not prompt me to set up the keyring, so it still seems to be impossible to set maestral up over SSH). I'm not sure whether this would work if I were not running an X session at all.

So I guess it's not really a bug, but it would be nice to be able to set up maestral under these conditions (i.e., over SSH even though there's an X session running, but not requiring interacting with the keychain popup), or at least somehow telling the user that this is what's happening. I don't know anything about how keychains work so I don't know how/if it would be possible to set it up from the CLI (maybe with some extra steps to configure the keychain from the terminal?).

samschott commented 8 months ago

Thanks for the detailed report and apologies for the slow response time.

Hanging indefinitely is not a great UX, maybe this could be solves by printing some message to the terminal notifying the user to unlock their keychain if not already done.

The interactions with the system keychain are handled by the keyring package and it does fall back to a plain text keyring (with an appropriate warning to the user) if no keychain can be accessed. The issue in your case I believe is the synchronous blocking until it's unlocked, which is not directly detectable to Maestral and possibly not at all from Python.

Still, I can imagine some pre-emptive message suggesting to ensure that the keyring is unlocked, which might help.