craigcitro/r-travis

"trying to use CRAN without setting a mirror"

jennybc opened this issue · 3 comments

I assume if I'm usinglanguage: r, the business end of my .travis.yml eventually leads here?

I haven't changed anything substantive in .travis.yml but have had many build failures in the past couple days. Is something changing here that affects what happens when my package builds?

The repo and file in question:

https://github.com/jennybc/googlesheets/blob/master/.travis.yml

Over the weekend, I got:

Warning: unable to access index for repository https://cran.rstudio.com/src/contrib :
  unsupported URL scheme

which caused me to switch from https to http. I did eventually have a few successful builds after that. That may have been a temporary glitch with RStudio? And yet I haven't been able to switch back to https. Whatever.

Now I am back to 100% failure but with a new error:

Installing R packages: rmarkdown
$ Rscript -e 'install.packages(c("rmarkdown"));if (!all(c("rmarkdown") %in% installed.packages())) { q(status = 1, save = "no")}'
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error in contrib.url(repos, type) : 
  trying to use CRAN without setting a mirror
Calls: install.packages -> grep -> contrib.url
Execution halted
The command "Rscript -e 'install.packages(c("rmarkdown"));if (!all(c("rmarkdown") %in% installed.packages())) { q(status = 1, save = "no")}'" failed and exited with 1 during .

I am trying to specify the CRAN mirror in no less than 2 different ways, but on twitter @jimhester said something that suggests nothing in my .travis.yml sets the CRAN mirror and probably never has: "FWIW previously R travis explicitly passed repos param (so setting repos in .Rprofile was ignored)". I'm aware that my setting of the CRAN environment variable has probably never had any effect on anything but left it in, figuring it was harmless.

Can anyone help? Are other people having success with language: R and if so, can I see a .travis.yml that actually works?

Paging @jimhester, who's been actively working on the travis side of all this.

Jenny, I suspect you'll get fixed up for now by adding:

before_install:
 - echo "options(repos = c(CRAN = "https://cran.rstudio.com"))" >.Rprofile

into your .travis.yml. This will just force the R mirror, and hopefully get you fixed up.

Jim, I think there's an issue here with cran setup -- if I'm reading r.rb right, it means that we never take the value of cran (the config setting) or CRAN (the environment variable) and use it to set an entry in .Rprofile -- I think we need a small block that takes that value and echoes it into .Rprofile, maybe if it's not already there?

One last tidbit: language: r actually uses the native support in Travis -- hopefully pretty soon, Jim's work will mean that we can finish moving everyone over and kill the confusion I created by having two versions. 😁 The docs there should ultimately be authoritative.

I assume if I'm using language: r, the business end of my .travis.yml eventually leads here?

Nope this repository is for the legacy travis-r script, language: r code is at https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/r.rb and issues should be opened at https://github.com/travis-ci/travis-ci/issues (this is mentioned in the preamble of each travis build).

https URLs have never been supported with language: r because the R package for Ubuntu 12.04 (Precise) is not compiled with libcurl support. I have an open PR (travis-ci/travis-build#618) to fix this, but it has not been merged or pushed to production yet.

All you need to do to set your cran repository is use

language: R
cran: http://cran.rstudio.com

Or you can now supply a dictionary to repos with named repositories

language: R
repos:
  CRAN: http://cran.rstudio.com
  ropensci: http://packages.ropensci.com

This is now detailed in the updated docs at https://docs.travis-ci.com/user/languages/r#Miscellaneous.

@craigcitro ~/.Rprofile is set at https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/r.rb#L107-L109

Setting CRAN the environment variable has AFAIK never been supported for language: R, its presence in your yaml must be vestigial from the r-travis script.

Also the default repository is already set as http://cloud.r-project.org which uses cloudfront mirrors in exactly the same fashion as cran.rstudio.org so in this case there is no need to change it from the default.

ok thanks!