ruby-install
ruby-install copied to clipboard
Check dependency with non-sudo
I know that I can skip dependency check with --no-install-deps
, but I’m proposing the default behavior to be:
- Check whether dependencies are satisfied without super-user permission.
- If some dependency is missing, install with super-user permission.
This way we can skip unnecessary sudo
without breaking any current behavior.
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)) ]
Anyone interested in this? I can make PR if this will be reviewed and merged.
Bump. Again, I can make PR.
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.
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“.
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 rpm
s, you can use rpm -q "${@}" | wc -l
).
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.
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 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.