Skip to content

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

@ablack3

Description

@ablack3

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions