Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support additional repositories besides CRAN #160

Open
eddelbuettel opened this issue Jul 21, 2015 · 4 comments
Open

Support additional repositories besides CRAN #160

eddelbuettel opened this issue Jul 21, 2015 · 4 comments

Comments

@eddelbuettel
Copy link
Contributor

I use drat to host tar.gz releases which I access from several machines.

It would be beneficial for Travis CI to access these too in lieu of going to GitHub---as I'd then continue to get by without devtools which is needed only for install_github().

Now, the code seems somewhat hardwired to using one repo only:

edd@max:~/git/r-travis/scripts$ grep CRAN travis-tool.sh | grep repos
    sudo add-apt-repository "deb ${CRAN}/bin/linux/ubuntu $(lsb_release -cs)/"
    Rscript -e 'install.packages(commandArgs(TRUE), repos="'"${CRAN}"'")' "$@"
    Rscript -e 'library(devtools); library(methods); options(repos=c(CRAN="'"${CRAN}"'")); install_github(commandArgs(TRUE), build_vignettes = FALSE)' "$@"
    Rscript -e 'library(devtools); library(methods); options(repos=c(CRAN="'"${CRAN}"'")); install_deps(dependencies = TRUE)'
edd@max:~/git/r-travis/scripts$ 

whereas my Rprofile.site now defaults to three:

local({
    r <- getOption("repos")
    r["CRAN"] <- "http://cran.rstudio.com"
    r["eddelbuettel"] <- "http://eddelbuettel.github.io/drat"
    r["ghrr"] <- "http://ghrr.github.io/drat"
    options(repos = r)
})

I'll see about a way to either add an install command also taking an alternate repo, or to add REPO2, REPO3, ... if set.

@craigcitro
Copy link
Owner

yeah, i'd thought we might be able to be clever and pack multiple repos into $CRAN, but that variable plays two roles (one in wget, the other in R).

i can think of two easy options -- and you're exactly the person i'd ask which is more sane! 😁

  • add a second variable, and spit out a working .Rprofile at startup.
  • try to wire a second variable to be included in all the commands you hit above.

i'm partial to the first, but you should let me know if it's a terrible idea.

alternately, you could add a step to just fetch a stored .Rprofile, but it'd be nice to automate this.

@eddelbuettel
Copy link
Contributor Author

Great minds think alike it seems :) Here is how far I got during my (short) train commute:

#!/bin/bash

set -e
#set -x
set -u

CRAN=${CRAN:-"http://cran.rstudio.com"}

## unset by default
DRAT_REPOS=${DRAT_REPOS:-""}

setRepos() {
    #echo "CRAN is ${CRAN}"
    #echo "DRAT_REPOS are ${DRAT_REPOS}"

    echo "local({"
    echo "   r <- getOption(\"repos\");"
    echo "   r[\"CRAN\"] <- \"${CRAN}\""
    for d in ${DRAT_REPOS}; do
        echo "   r[\"${d}\"] <- \"https://${d}.github.io/drat\""
    done        
    echo "   options(repos=r)"
    echo "})"
}

setRepos

which then does

edd@don:~/git/r-travis/scripts(master)$ ./tryDrats.sh 
local({
   r <- getOption("repos");
   r["CRAN"] <- "http://cran.rstudio.com"
   options(repos=r)
})
edd@don:~/git/r-travis/scripts(master)$ DRAT_REPOS="eddelbuettel ghrr" ./tryDrats.sh 
local({
   r <- getOption("repos");
   r["CRAN"] <- "http://cran.rstudio.com"
   r["eddelbuettel"] <- "https://eddelbuettel.github.io/drat"
   r["ghrr"] <- "https://ghrr.github.io/drat"
   options(repos=r)
})
edd@don:~/git/r-travis/scripts(master)$ 

Next step is to just echo appending to ~/.Rprofile for ease of use.

That is 'good enough for me' as it just loops over drats and uses their implied syntax. Some folks (Hi, @cboettig) insist on different free-form repos (still managed by drat). Then there are of course non-drat repos. Not sure yet how to easily deal with that.

@eddelbuettel
Copy link
Contributor Author

Tried with this commit (and two more for cleanups), but failed. Too bad.

@jangorecki
Copy link

I see the cran field in the travis yml definition: http://docs.travis-ci.com/user/languages/r/#Miscellaneous
If it could take a list of CRAN urls and adjust globally it would be perfect.

@eddelbuettel I do believe R base could have a helper function to append urls to cran repos just for convenience. Maintaining CRAN will not scale if developers will keep the trend. Anyway it would not solve discussed issue which needs to append repos from the travis yml level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants