pkgx
pkgx copied to clipboard
Use SUDO_HOME environment variable to derive the pkgx directory if it is set
This fixes an issue on Linux when using sudo which causes the pkgx directory to be located inside the root user home directory. This seems to be due to differences in how operating systems deal with sudo and the HOME environment variable. On macOS, the HOME variable is set to the home directory of the user calling the sudo command, but on Fedora it is set to the root user home directory. By using SUDO_HOME if it set, we fix the Linux behavior to be the same as on macOS.
Together with this other PR in pkgm, this fixes calling sudo pkgm install <package> on Linux to install packages to /usr/local/bin. See full discussion for more information.