R - install packages in different ways
Hi !
Recently I had to debug a problem installing R packages with OpenBSD. To put it simply, I needed to use “httpuv-1.6.6 and +” but at the very end of the installation I collected a “core dump”. Since I haven’t found the reason yet, I’ll come back to this in a later post.
While debugging I had to test the installation of the package again and again so I will do a brief recap of the methods employed.
Let’s go.
- There is the most obvious method, using the ‘install.packages()’ function from the interpreter.
> install.packages("httpvuv")
- Then comes the method via the command line with a little subtlety to always install the current package
Let’s start by creating an R file that will call the package installation function. Since the name of the file doesn’t matter, let’s call it ‘foo.R’
File ‘foo.R’:
# https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/install.packages
install.packages(commandArgs(trailingOnly = TRUE), repos='https://cran.rstudio.com')
Now let’s call it via the RScript binary and give it the name of the package we want to install as a parameter.
$ Rscript foo.R "httpuv"
- And finally, the last method I used, again the use of the command line to install a particular version via its sources.
$ R CMD INSTALL /tmp/httpuv_1.6.6.tar.gz
I must add that in the current state on my version of OpenBSD (7.3), only version 1.6.5 of httpuv installs without problem. If I want to use later versions (1.6.6 and +), I have to use the previous command with a slight modification.
$ R CMD INSTALL /root/Downloads/httpuv_1.6.6.tar.gz --no-test-load
This one allows me to not have a core dump. As I indicated above, I will come back to this anomaly in a later post.
Regards