How to get/make/prepare tar.gz file from github source of R dev package ?

Hi,

I want make a tar.gz file in order to make a .zip windows binary file subsequently using it.

Ho do I do it using following repo:

https://github.com/omegahat/RDCOMClient

In order to make a zip binary file I need tar.gz file first. What if a package is not on Cran archive and only has got a repo on github but there is no tar.gz file over there.

Hi All again,

There is a description here, but is a bit old, is it still valid or anything has changed in the meantime ?

https://www.biostat.wisc.edu/~kbroman/Rintro/Rwinpack.html

But still tar.gz is needed so my question still stands: how to prepare tarball (tar.gz) first, please ?

It's unclear to me what you are trying to do. Do you just want to install RDCOMClient? Are you trying to make a tarball of it to install it on a computer without Internet?

Hi, thank you @AlexisW for responding.

I would like to:

  1. Prepare windows binary zip file for RDCOMClient package because that type of file is not available on Cran or github, so I want to prepare it myself - this could be used to install that package or others on the computer without internet connection.
  2. I would like to know how to do it step-by step provided that first step in that process I assume, is to build tar.gz archive which is called tarball and all the files I need are placed on github site of RDCOMClient package.
  3. I have read several tutorials and SO replies involving R CMD INSTALL command, but can't get it to work.
  4. Can you help please ?

PS. I installed that package in my RStudio working on windows 10 (by compiling it from downloaded source), so I have got this package installed but wanted to learn how to build binary for windows.

I see better. Basically what you need to do is to first, download the code, second, get into the code directory and follow the instructions to create a package, as if it was a package you just wrote.

For downloading the code, easiest is to go on the Github page, click on the green <> Code button and select Download ZIP. If you're familiar with git, you can also fork the repo and make a local clone.

Now, you have the zip file on your computer, unzip it, and create a new RStudio project in that existing directory (RStudio is not necessary, but can help for the first pass).

When you're in this Project, run devtools::check() (you might need to install {devtools}). This is a wrapper for R CMD CHECK, I'll come back to it. If everything worked well, you'll see a lot of text as many aspects of the package are tested, and it should end with 0 errors (on my computer it also has 1 warning and 3 notes, we can ignore them for now).

Then, run devtools::build(), this should be much faster, and end by giving you the path to the tarball it just created! If you want the tarball to be installable on Windows easily, instead run devtools::build(binary = TRUE), the file created will be .zip instead of .tar.gz. You can now say that you fulfilled your goal and stop here.

To install this package on a separate (Windows) computer, run:

install.packages("C:\path\to\RDCOMClient_0.96-1.zip")

If you want to understand better, what I just used is the approach described in the r-pkgs book. I highly recommend that you read the first part, especially the structure chapter.

Now, we "cheated" a bit, because we used the devtools wrappers. Actually check() and build() themselves are calling R CMD CHECK and R CMD BUILD, which is the more "traditional" way of building packages. To understand all of it, you need to read the "Writing R extensions" manual.

In brief, as previously, make sure the code is downloaded and ready. Then open a Windows terminal (e.g. cmd), then use cd and dir to navigate to the directory with the package, and run this command:

R CMD check .

You should see about the same text as with devtools::check() from within R. In my case, this check failed with a LaTeX error, which is not unexpected, so I won't try harder. If you wish to, you can check the R CMD BUILD section of the manual.

1 Like

Hi, thank you very much, I will try that.

What do you mean by that ?
Does it mean that devtools way is better than directly calling:

R CMD

as you were able to complete building zip file with devtools, only warnings were given, but with R CMD it failed with something related to LaTex ?

cheers and thank you again.

I'm not fully sure of the explanation, as the question of LaTeX installations is something I'd rather not think about too much :slight_smile:

On my current computer, I haven't installed a full LaTeX distribution. So my guess is that R CMD check is looking for one, and can't find it, thus error.

However, when installing RStudio and standard packages, I probably installed stuff related to quarto and Rmarkdown, and it probably installed the tinytex package in the process. So I'm expecting devtools developers to be aware that many R users won't have a full LaTeX distribution on their system, but will have tinytex installed from within R, and devtools::check() might look for this distribution.

It's likely that I could get R CMD to look for tinytex by defining the right variable somewhere, I'd have to look into it.

I never looked in details under the hood, my understanding is that devtools does exactly the same thing as R CMD, but adding a few steps to address common pain points. So, as a not-too-advanced user, I would say the devtools way is usually "better", or at least easier.

Thank you, much appreciated.

To obtain a tar.gz file from a GitHub source of an R development package, you can follow these general steps:

  1. Clone the Repository: Start by cloning the GitHub repository containing the R development package to your local machine. Open your terminal or command prompt and navigate to the desired directory where you want to clone the repository. Use the following command:

bashCopy code

git clone <repository_url>

Replace <repository_url> with the URL of the GitHub repository.

  1. Build the Package: Once the repository is cloned, navigate to the project directory. Look for a file called DESCRIPTION within the directory. This file contains metadata and package information. Open a terminal or command prompt within the project directory and use the following command to build the package:

objectivecCopy code

R CMD build .

This command will create a tarball file (.tar.gz) of the package in the current directory.

  1. Obtain the Tarball: After running the build command, the tarball file will be generated. It will typically have a name similar to <package_name>_X.X-X.tar.gz, where X.X-X represents the package version. You can locate the tarball file in the current directory.

Now you have successfully created the tar.gz file from the GitHub source of the R development package. You can use this tarball for various purposes such as installation, distribution, or sharing with others.

What do I need/use that file for ?

Is it possible to build binary zip file to specified folder, different to that folder I am currently in ?

I don't think you can do that directly on the command line with R CMD build. In that case, you should first run it in the directory itself, the tarball will be created in the parent directory, then you can copy or move the tarball using move (on Windows, or mv on other systems).

If you do it from within R, you can use the path = argument to devtools::build(). If you were to look at its source code, you'd see that it literally calls R CMD build and then file.copy(tarball, path).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.