I am working on a package that supports interaction with an alternatively shaped library structure which supports installing multiple versions of a package in parallel (RVClibrary, soon on CRAN). Recently, I met some strange behaviour and I hope someone can explain.
When installing a package, it can sometimes have a source version which is later than the binary version. The source (uncompiled C code) is in that case not yet compiled (by ...?) but contains a later version than the already compiled binary version. The following is shown in my case:
There is a binary version available but the source version is later:
binary source needs_compilation
rlang 0.2.0 0.3.4 TRUE
A choice is given to the user whether A or B should be relatively installed or compiled. In other words, if you want version 0.2.0 or 0.3.4 (for which you need Rtools).
This choice will not be given when the install.packages.compile.from.source
option is set.
> options(install.packages.compile.from.source = "always")
> install.packages('rlang', lib = "C:\\test", quiet = TRUE, repos = "http://cran.us.r-project.org")
There is a binary version available but the source version is later:
binary source needs_compilation
rlang 0.2.0 0.3.4 TRUE
installing the source package ‘rlang’
The source is installed.
But when I create a simple script (I name it install_test.R
):
packageName <- commandArgs(trailingOnly = TRUE)[1]
cat(packageName, '\n')
options(install.packages.compile.from.source = "always")
install.packages(packageName, lib = "C:\\test", quiet = TRUE, repos = "http://cran.us.r-project.org")
The following behaves the same with system in R and directly in CMD.
(Make sure you have the path to Rscript.exe
in your environment variable PATH)
> system("Rscript.exe C:\\test\\install_test.R rlang")
rlang
There is a binary version available but the source version is later:
binary source needs_compilation
rlang 0.2.0 0.3.4 TRUE
Binaries will be installed
package 'rlang' successfully unpacked and MD5 sums checked
The Binaries are installed!
I need to be able to always install the Source version so I do not run into dependency issues. ggplot2 for example depends on >= 0.2.1
already...
Summary
- I have Rtools 3.5 installed (which devtools can find using both routes and thinks it is not compatible..., but installing from source works fine in Rstudio, and (https://cran.r-project.org/bin/windows/Rtools/) CRAN says it's compatible to)
- R version:
platform x86_64-w64-mingw32
arch x86_64
os mingw32
system x86_64, mingw32
year 2016
month 06
day 21
svn rev 70800
language R
version.string R version 3.3.1 (2016-06-21)
nickname Bug in Your Hair
- running Windows 10
- The difference between environment variables can be seen here (Rstudio to the right, Rscript left): https://pasteboard.co/IasIVMe.png
(my edit here is removed to keep it clean. See my answer (or history) to read more)