Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid using /usr/bin/tar on Debian machines #198

Open
kevinushey opened this issue Jan 23, 2024 · 5 comments
Open

Avoid using /usr/bin/tar on Debian machines #198

kevinushey opened this issue Jan 23, 2024 · 5 comments

Comments

@kevinushey
Copy link

This is a follow-up from rstudio/renv#1794.

For the builds of R published on https://docs.posit.co/resources/install-r, it looks like R is configured to use system installations of tar and sed as so:

$ cat Renviron | grep 'SED\|TAR'
SED=${SED-'/usr/bin/sed'}
TAR=${TAR-'/usr/bin/tar'}

This can be problematic in rare scenarios, as /usr/bin/sed and /usr/bin/tar are not actually provided by any apt packages. So, if those programs are not available for some reason, it's not clear for the user on how to recover.

Some other similar instances:

$ cat Renviron | grep /usr/bin/
R_PRINTCMD=${R_PRINTCMD-'/usr/bin/lpr'}
R_TEXI2DVICMD=${R_TEXI2DVICMD-${TEXI2DVI-'/usr/bin/texi2dvi'}}
R_GZIPCMD=${R_GZIPCMD-'/usr/bin/gzip'}
R_UNZIPCMD=${R_UNZIPCMD-'/usr/bin/unzip'}
R_ZIPCMD=${R_ZIPCMD-'/usr/bin/zip'}
R_BZIPCMD=${R_BZIPCMD-'/usr/bin/bzip2'}
PAGER=${PAGER-'/usr/bin/pager'}
R_PDFVIEWER=${R_PDFVIEWER-'/usr/bin/xdg-open'}
SED=${SED-'/usr/bin/sed'}
TAR=${TAR-'/usr/bin/tar'}

In other words, for each of these programs, if a variant exists in /bin, I think that version should be preferred.

@glin
Copy link
Contributor

glin commented Jan 24, 2024

I bet this is the same issue we once got with /bin/sed vs. /usr/bin/sed before, #72. On recent Ubuntu/Debian, /bin was merged into /usr/bin so with stock docker images like the one we're using, tar is actually at /usr/bin/tar with /bin/tar being a symlink:

docker run -it --rm ubuntu:focal

$ ls -la /bin
lrwxrwxrwx 1 root root 7 Aug 26  2022 /bin -> usr/bin

$ readlink -f /bin/tar
/usr/bin/tar

This causes issues for unmerged systems (if you've upgraded from an older OS perhaps?) and other things unfortunately: https://lwn.net/Articles/890219/

So for newer Ubuntu and Debian builds, we could override the TAR location to /bin/tar. I believe the Ubuntu builds already manually set some bin locations like ZIPCMD but not TAR. But also, I wonder if this could also cause issues if /bin is supposedly intended to be eliminated eventually.

If we want to set TAR and prevent issues from unmerged /usr systems, there are some other variables that the distro default r-base sets as well for reference: https://salsa.debian.org/edd/r-base/-/merge_requests/1

@gaborcsardi
Copy link
Contributor

Yeah, it is the upgrades that cause issues, the symlinks are missing on upgraded systems.

@kevinushey
Copy link
Author

Thanks; I wasn't aware of that! For what it's worth:

$ dpkg -L tar | grep /bin/tar
/bin/tar

$ dpkg -L sed | grep /bin/sed
/bin/sed

which I think gives some (small) amount of motivation to prefer /bin/tar over /usr/bin/tar.

@gaborcsardi
Copy link
Contributor

We had this in rig some time ago, for sed (r-lib/rig#119 (comment)), apparently it also applies to tar.
It would be nice to fix it properly.

@mabuimo
Copy link

mabuimo commented Jan 31, 2024

I bet this is the same issue we once got with /bin/sed vs. /usr/bin/sed before, #72.

Indeed, I also needed to manually create symlinks for that directory (Ubuntu 20.04 LTS).
ln -s /bin/tar /usr/bin/tar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants