DopplerHQ / cli

The official CLI for interacting with your Doppler secrets and configuration.
https://docs.doppler.com
Apache License 2.0
218 stars 45 forks source link

[BUG] `dopper update` fails on Arch Linux #191

Closed elldritch closed 1 year ago

elldritch commented 3 years ago

Here's the result of doppler update --debug, running on Arch Linux:

➜ doppler update --debug
Debug: Using config file /home/leo/.doppler/.doppler.yaml
Debug: Reading config file
Debug: Checking for latest version of the CLI
Debug: Performing HTTP GET to https://api.github.com/repos/DopplerHQ/cli/releases/latest
An update is available.
? Install Doppler CLI v3.23.1 Yes
Updating...
Debug: Performing HTTP GET to https://cli.doppler.com/install.sh
Debug: Writing to temp file /home/leo/.install.sh.024855874
Debug: Executing install script
Debug: Executing "/home/leo/.install.sh.024855874 --debug"
DEBUG: Detected OS 'linux'
DEBUG: Detected architecture 'amd64'
DEBUG: Detected format 'rpm'
DEBUG: Checking for gpg binary
DEBUG: Using temp directory /home/leo/.tmp.phAvVJhH
Downloading latest release
DEBUG: Using /usr/bin/curl for requests
DEBUG: Downloading binary from https://cli.doppler.com/download?os=linux&arch=amd64&format=rpm
DEBUG: Download binary signature from https://cli.doppler.com/download/signature?os=linux&arch=amd64&format=rpm
DEBUG: Download public key from https://cli.doppler.com/keys/public
DEBUG: Downloaded CLI v3.23.1
DEBUG: Verifying GPG signature
DEBUG: Signature successfully verified!
Installing...
error: cannot open Packages database in /var/lib/rpm
error: cannot open Packages database in /var/lib/rpm
ERROR: script failed during execution
DEBUG: Removing temp directory

Unable to install the latest Doppler CLI
Doppler Error: exit status 1

My guess is that the problems arise from the following snippets in install.sh:

Package manager detection: https://github.com/DopplerHQ/cli/blob/ef7601fded3157faa1e6736c667b231c9f6b0509/scripts/install.sh#L144-L150

RPM installation: https://github.com/DopplerHQ/cli/blob/ef7601fded3157faa1e6736c667b231c9f6b0509/scripts/install.sh#L274-L286

There are two problems here:

  1. Even though I have rpm installed, that's actually not my primary package manager. My primary package manager is pacman. I have rpm installed for development purposes (I totally get that this is an edge case for users).
  2. Even if rpm were my primary package manager, rpm -i requires sudo, so this was always doomed to fail.

My recommendation is to always try to install into /usr/local/bin (or in the location of an existing which doppler), and not bother trying to interact with package managers. On developer workstations, I expect you'll frequently run into the "package manager requires sudo" problem, and in CI or other automated environments (where the user may actually be running as root), your users probably don't want to be automatically downloading and executing an arbitrary update anyway.

(As another note, I also manage an open source CLI repository. I've found it very useful to add directions into the bug reporting template to provide the --debug output. You might want to do the same.)

Piccirello commented 3 years ago

Doppler CLI installs and updates both currently require sudo due to their installing the CLI into your PATH. We have plans to support updating the CLI based on its current location, but currently we only support installing/updating the CLI that's installed globally on your machine.

Thanks for that tip about recommending --debug output, I'll add that to our bug template.

elldritch commented 3 years ago

Doppler CLI installs and updates both currently require sudo

Sure. I'm suggesting that, when installing via package manager, the install script should ask for sudo (e.g. the install script could call sudo rpm -i) rather than expecting the user to run sudo doppler update. systemctl does this when it needs authentication, and wg-quick does something similar.

(Perhaps alternatively, download the package and then print "run rpm -i PACKAGE_FILE to finish the install".)

Personally, I am very reluctant to run sudo doppler update just to get updates. In general, I am reluctant to run arbitrary binaries under sudo.

due to their installing the CLI into your PATH.

Another possibility is to take the ghcup-ish approach and install to $HOME/.local/bin, and then tell the user to add $HOME/.local/bin to $PATH.


In either case, I've worked around this by just manually updating my local doppler from a GH release, so this is not an urgent ask - just some suggestions when you get around to fixing this.

Thanks for that tip about recommending --debug output, I'll add that to our bug template.

Glad I could be helpful!

pedrobonifacio commented 2 years ago

How can we get around this today and install doppler on arch linux based distros?

ryan-blunden commented 2 years ago

@elldritch: Are you happy for me to close out this ticket?

@pedrobonifacio: If your issue is related to installing the CLI on Arch Linux could you open a new ticket or ask for help in the Doppler Community Forum