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

drat::addRepo() does not persist across R sessions and does not work in .Rprofile #20

Open
ablack3 opened this issue Jun 9, 2020 · 1 comment

Comments

@ablack3
Copy link

ablack3 commented Jun 9, 2020

Starting from a new R session I can add a repo using drat::add_repo() as expected.

getOption("repos")
#>                        CRAN 
#> "https://cran.rstudio.com/" 
#> attr(,"RStudio")
#> [1] TRUE
drat::addRepo("OHDSI")
getOption("repos")
#>                            CRAN                           OHDSI 
#>     "https://cran.rstudio.com/" "https://OHDSI.github.io/drat/" 
#> attr(,"RStudio")
#> [1] TRUE

However when I restart R I would expect the repo to remain but it appears to be removed.

# After restarting R
getOption("repos")
#>                        CRAN 
#> "https://cran.rstudio.com/" 
#> attr(,"RStudio")
#> [1] TRUE

I added the following code to my .Rprofile in my user home directory

message("Running .Rprofile for user")
drat::addRepo("OHDSI")
message(paste("Repos are:", paste(getOption("repos"), collapse = ";   ")))

When I restart R I see

#> Restarting R session...

#> Running .Rprofile for user
#> Repos are: @CRAN@;   https://OHDSI.github.io/drat/

But when I check the repos option I don't see the new repo.

getOption("repos")
#>                        CRAN 
#> "https://cran.rstudio.com/" 
#> attr(,"RStudio")
#> [1] TRUE

I'm I correct that this behavior is unexpected? How should I add a repo that persists across R sessions? Why does running getOption("repos") in .Rprofile show the repo when running it interactively does not?

Thanks!

@rogerssam
Copy link

rogerssam commented Oct 22, 2020

Hi Adam, see this issue.

If you don't explicitly set the CRAN repo, it appears that Rstudio overwrites it on load. So you will need to set both repos explicitly in your .Rprofile file e.g.

options(repos = c(CRAN="https://cloud.r-project.org/"))    # Preferred CRAN mirror
drat::addRepo("OHDSI")

Then the OHDSI repo should persist across sessions.

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

2 participants