ruby-install icon indicating copy to clipboard operation
ruby-install copied to clipboard

Check dependency with non-sudo

Open FranklinYu opened this issue 5 years ago • 9 comments

I know that I can skip dependency check with --no-install-deps, but I’m proposing the default behavior to be:

  1. Check whether dependencies are satisfied without super-user permission.
  2. If some dependency is missing, install with super-user permission.

This way we can skip unnecessary sudo without breaking any current behavior.

FranklinYu avatar Mar 14 '19 02:03 FranklinYu

Affected function:

https://github.com/postmodern/ruby-install/blob/ea2b8bbff87ea4340d965e72ac3acfb4ab1d1766/share/ruby-install/package_manager.sh#L32-L54

For example with APT we can have

[ `dpkg -l "$@" | grep ii | wc -l` = $# ]

In MacPorts

[ `port installed active "$@" | wc -l` = $(($# + 1)) ]

FranklinYu avatar Mar 19 '19 14:03 FranklinYu

Anyone interested in this? I can make PR if this will be reviewed and merged.

FranklinYu avatar May 30 '19 13:05 FranklinYu

Bump. Again, I can make PR.

FranklinYu avatar Jan 08 '20 10:01 FranklinYu

I like the idea but I'm a bit worried about portability with the check for satisfied dependencies. If we could get those where they work reliably, it seems nice to me.

havenwood avatar Jan 09 '20 16:01 havenwood

wc -l is POSIX. My use of grep is basic and also POSIX (because no option is used). Actually dpkg -l should only list installed packages, but uninstalled packages with configuration files left over are still counted as “installed packages“.

FranklinYu avatar Jan 10 '20 05:01 FranklinYu

As a first time user a sudden sudo surely is not what I did expect, and not knowing what is executed feels dangerous. I would love this issue to be addressed (for rpms, you can use rpm -q "${@}" | wc -l).

bloerwald avatar Sep 09 '20 09:09 bloerwald

I think we would need to add a separate function that only checked whether one (or maybe more?) dependencies were already installed? The function would need a similar case/esac statement for each package manager. If we could use the simplest command possible to query whether the package was installed or not (avoiding complex grep/sed parsing) I think that would work.

postmodern avatar Jan 07 '22 04:01 postmodern

An alternative would be to list the dependencies as "files", not packages, then checking will never require sudo, and will not depend on the package manager (and will work even with packages installed manually.

eloyesp avatar Mar 21 '22 14:03 eloyesp

@eloyesp I think some dependencies (like libyaml and libffi) are libraries, not executables, so they cannot be searched in “path”. I feel that using package manager itself is still easier.

FranklinYu avatar Apr 29 '22 00:04 FranklinYu