tim
tim

Reputation: 3608

Request the latest CRAN package version by source when binaries not yet up

I wish to help users install a package from CRAN where the latest source is newer than the Windows and MacOS binaries.

So, to give a concrete example, install.packages("umx") installs the the most recent binary, but this is older than the source version accepted on CRAN.

install.packages doesn't alert user that a newer source is available.

However, the user can get the newest source by going to the CRAN page, looking up the direct link, and using that as the input for pkgs in install.packages:

browseURL("https://cran.r-project.org/web/packages/umx/index.html") 
install.packages("https://cran.r-project.org/src/contrib/umx_1.7.5.tar.gz")
# newest version (1.7.5) installed from source.

But I want a more automated method to request the latest source. I thought that requesting type = "source" would get the latest source, but it tries to get the source of the older (1.55) version for which binaries are available, and fails:

install.packages("umx",  type= "source")
... URL 'https://cran.rstudio.com/src/contrib/umx_1.5.5.tar.gz': status was '404 Not Found'

Any solutions?

Upvotes: 1

Views: 869

Answers (1)

Joris Meys
Joris Meys

Reputation: 108613

I do get a whole set of warnings and errors when trying to build from source, mainly because XML doesn't want to build cleanly. If you install with type = "source", all dependencies will be installed from source as well. However, if I just do:

install.packages("umx")

it does warn me that there's a newer source version and it installs version 1.7.5 from source, while it installs all dependencies as binary. This is because the default option for the argument type is "both", which means on Windows that it installs binary unless there's no binary or a more recent source version.

If you don't see that warning, try forcing it using

install.packages("umx", type = "both")

Note this requires Rtools to be installed. Rtools is not a package, but a toolset needed to build packages from source. Rtools is available for download on CRAN. Be sure to read the installation instructions carefully!

As per today and on R3.3.3,

install.packages("umx", type = "source") 

does try to install umx version 1.7.5 from source, together with a whole set of other packages btw. It fails as explained above due to errors in compilation for the XML (and possibly other) package(s).

Installing specific/older versions from source

If you want to install a specific version, just download the .tar.gz file of the related version, store on your computer and install using:

install.packages("path/to/umx_1.7.5.tar.gz", type = "source", repos = NULL)

This will install the downloaded .tar.gz file, but you'll have to ensure yourself that all dependencies are installed before you build this package from source.

Checking whether there is a problem

Keep in mind though that installing from source is not always a smart idea. You should check at least the check results for the package on CRAN. In this case it seems that version 1.7.5 can cause troubles, as shown by the CRAN results for the different builds at https://cran.r-project.org/web/checks/check_results_umx.html

enter image description here

Upvotes: 2

Related Questions