r-lib / rig

The R Installation Manager
MIT License
663 stars 22 forks source link

Rig's R install fails at Pak Install Stage on Ubuntu 20.04 with "Failed to find user HOME" #228

Open chrisphe opened 6 months ago

chrisphe commented 6 months ago

When installing an R runtime, Rig fails with the following error:

[INFO] Installing pak for R 4.3.2 (if not installed yet) [ERROR] Failed to install pak for R 4.3.2: Failed to find user HOME

Currently, we have been able to work around this with the '--without-pak' switch.

The issue arises because of how Rig determines a user's home directory in https://github.com/r-lib/rig/blob/dac0aaa2736a5caf4288981a430f52da1114e8d2/src/utils.rs#L231

The above referenced code attempts to extract the home directory from /etc/passwd. In the Linux environment I am using there is no user entry in /etc/passwd due to the way user logins are managed. To resolve this it would be great if Rig could fallback to using $HOME environment variable if the home directory cannot be extracted from /etc/passwd.

Something like the following should address this:

let user_record = nix::unistd::User::from_uid(ouid)
.or(env::var("HOME"))?
.ok_or(SimpleError::new("Failed to find user HOME))?;
gaborcsardi commented 6 months ago

Ah, thanks a lot for the debugging, will fix soon!

natemcintosh commented 6 months ago

I know adding a new dependency might not be ideal, but the home crate is pretty good at getting a user's home directory.