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

untar() can fail strangely on Windows causing confusing error message in renv::restore() #521

Closed
AshesITR opened this issue Aug 21, 2020 · 4 comments

Comments

@AshesITR
Copy link

I had a problem with renv::restore() because untar() used tar.exe from Git for Windows.
That version of tar needs paths like /C/myfile.tar.gz instead of C:/myfile.tar.gz and throws the error message

/usr/bin/tar: Cannot connect to C: resolve failed

While the problem can be fixed locally using Sys.setenv(TAR = ...) to another version of tar, the error is far from obvious, because renv stops with the error file not found (as it tries to download the same tarball from another repo which may not contain the package in question).

If renv:::renv_archive_list_impl used a specific version of tar (maybe installed with renv::equip()?) or used tar = "internal", the error would not occur.

@kevinushey
Copy link
Collaborator

Thanks for the bug report! I agree that using R's internal tar here is the right approach. I've made a change in the development version of renv here:

cd7a564

Let me know if this seems like the right solution. It does change the value of the TAR environment variable globally when renv is loaded (only if it was unset previously).

@kevinushey
Copy link
Collaborator

As an aside, newer versions of Windows come with their own tar implementation, e.g. at

C:\Windows\System32\tar.exe

so I wonder if we could / should use that instead of R's internal implementation as well.

@AshesITR
Copy link
Author

That Version does work, as does the one shipping with RTools (tested 3.5 and 4.0)

Not you don't need to set TAR, it can be passed as an argument to untar in the various places renv calls it.

@AshesITR
Copy link
Author

AshesITR commented Sep 3, 2020

@kevinushey I'd avoid Sys.setenv() like this:

Change

tar = untar(path, list = TRUE),

to

tar = untar(path, list = TRUE, tar = Sys.getenv("TAR", unset = if (renv_platform_windows()) "internal" else ""))

@hadley hadley closed this as completed Apr 28, 2023
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

3 participants