rstudio / renv

renv: Project environments for R.
https://rstudio.github.io/renv/
MIT License
998 stars 152 forks source link

Warning: requested TAR '/usr/bin/tar' does not exist; using '/bin/tar' instead (renv 1.03, R 4.3.2, Ubuntu 20.04 LTS) #1794

Closed mabuimo closed 7 months ago

mabuimo commented 8 months ago

Hi, I have noticed that when I load any project which uses renv 1.03 under Ubuntu 20.04 LTS and using R 4.3.2 I get this warning:

renv::activate()
Warning message:
requested TAR '/usr/bin/tar' does not exist; using '/bin/tar' instead 

Restarting R session...

Warning message:
requested TAR '/usr/bin/tar' does not exist; using '/bin/tar' instead 

I don't get this message if I use R 4.2.2, Ubuntu 20.04 LTS, and renv 1.03.

kevinushey commented 8 months ago

R uses the value of the TAR environment variable when attempting to figure out what tar executable should be used. It looks like you have TAR set to a location that doesn't exist, so renv is detecting that and recovering.

That said, I don't know how your machine got into this state, since:

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.6 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.6 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

$ which -a tar
/usr/bin/tar
/bin/tar

You could try manually reinstalling tar, e.g. sudo apt install tar.

mabuimo commented 8 months ago

Hi, thanks for your answer. $ cat /etc/os-release provides the same output you shared.

Reinstalling tar didn't help:

# apt reinstall tar
# which -a tar
/bin/tar

I eliminated the above-mentioned warning creating a symlink:

# ln -s /bin/tar /usr/bin/tar
# which -a tar
/usr/bin/tar
/bin/tar
kevinushey commented 8 months ago

Strange, it looks like you're right... but I've always seen a tar installation at /usr/bin/tar, even though it's not provided by any apt package. Even a plain Ubuntu 20.04 Docker image has /usr/bin/tar available.

Either way, your solution should be fine, but the alternative would be to find where the TAR environment variable is being set and update that. Usually that's set here:

$ cat $(R RHOME)/etc/Renviron | grep tar
## used by untar(support_old_tars = TRUE) and installing grDevices
## Prefer a tar that can automagically read compressed archives
TAR=${TAR-'/bin/tar'}

so it might be worth checking whether your R installation is referring to /usr/bin/tar instead of /bin/tar.

mabuimo commented 8 months ago
cat $(R RHOME)/etc/Renviron | grep tar
## used by untar(support_old_tars = TRUE) and installing grDevices
## Prefer a tar that can automagically read compressed archives
TAR=${TAR-'/usr/bin/tar'}

it seems R refers to /usr/bin/tar as you indicated. What could be the cause?

kevinushey commented 8 months ago

How was R installed?

mabuimo commented 7 months ago

Hi, I followed these installation steps:

apt-get update
apt-get install gdebi-core
export R_VERSION=4.3.2
curl -O https://cdn.rstudio.com/r/ubuntu-2004/pkgs/r-${R_VERSION}_1_amd64.deb
gdebi r-${R_VERSION}_1_amd64.deb

Thank you.

kevinushey commented 7 months ago

Thanks! I think this is an issue with the binary builds of R being distributed by Posit then -- it should prefer using /bin/tar instead of /usr/bin/tar here. I'll forward this issue on in the appropriate channels.

kevinushey commented 7 months ago

In the meantime, I think we've found a workaround for your case (use a symlink in /usr/bin) and I think that will be sufficient.