Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli installation: better handling of sudo #99

Open
G4Vi opened this issue Aug 19, 2024 · 3 comments
Open

cli installation: better handling of sudo #99

G4Vi opened this issue Aug 19, 2024 · 3 comments

Comments

@G4Vi
Copy link
Contributor

G4Vi commented Aug 19, 2024

Currently the installation invoke sudo if the user is not root and $out_prefix is not in $HOME. This heuristic has a lot of false positives, all of the failures I looked at http://matrix.cpantesters.org/?dist=Alien-libextism%20v0.1.1 appear to be the cli install script attempting sudo in a scenario where it shouldn't.

If we insist on installing with sudo, rather that attempting to detect when it's needed, we should try without, and on permission error retry with sudo.

However, instead I think we should make two changes:

  • Don't use sudo at all in the install script. I will use sudo or run it as root myself if I am going to install somewhere that I don't have write access to.

  • Install the cli to a $HOME directory by default. After installing the file on disk, to get it in $PATH, I prefer when it spits out instructions rather than appends to a dot file, as I know best how to handle my own dot files (I append to .profile on my systems for efficiency reasons, though it requires logging out and back in for it to take effect). This removes the need for root/sudo for the default install case. If we wanted to we could add a flag to get a system install that just sets the prefix to /usr/local/bin.

@nilslice
Copy link
Member

SGTM! @zshipko may have some thoughts / direction to add. But please do make any improvements you have in mind.

Will only add that if it impacts the install process, that we update the README and docs throughout the extism.org site etc.

@zshipko
Copy link
Contributor

zshipko commented Aug 20, 2024

Yeah, I think either of those solutions sound good - it sounds like the first option is a little more automatic, but both are common patterns people will be used to. We should just make sure to test all the edge cases before updating all the docs - I'm happy to help with that when you're ready.

@bhelx
Copy link
Contributor

bhelx commented Sep 20, 2024

Note: can borrow from or re-use XTP cli script: https://static.dylibso.com/cli/install.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants