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

@CRAN@ message #10

Closed
jameshunterbr opened this issue Jan 23, 2019 · 2 comments
Closed

@CRAN@ message #10

jameshunterbr opened this issue Jan 23, 2019 · 2 comments
Assignees

Comments

@jameshunterbr
Copy link

I receive the following warning from R when using shelf:

1: In librarian::shelf(tidyverse, Biostrings, seqinr, msa, kableExtra, :
cran_repo = '@cran@' is not a valid URL.
Defaulting to cran_repo = 'https://cran.r-project.org'.

I can't seem to find any other reference to @cran@, so I'mlisting it as an issue. Librarian defaults to where it should go anyway, so I'm not sure what's happening with the "cran_repo". Is it something in my R.profile file or does it come from your package?
Librarian shouldn't need to refer to CRAN as all the packages in the list above are on my drive. There is no actual problem in loaded them. That happens normally.
Hope this is useful.

Thanks,

Jim Hunter

@DesiQuintans
Copy link
Owner

DesiQuintans commented Jan 23, 2019

Hi Jim, this is normal and you haven't done anything wrong. This is part of the input checking that Librarian does, colliding with a weird thing that R does to define a default CRAN URL. I have more details below, but this warning simply means that since you haven't manually defined a CRAN repo in the cran_repo argument, and R is running in an environment where it has not been set already, then shelf() has set a sane default value for you. You have three courses of action:

  1. The warning can be safely ignored.
  2. You can manually set the cran_repo argument to a valid CRAN URL, like cran_repo = "https://cran.r-project.org".
  3. You can set the argument quiet = TRUE.

Re. why this happens, shelf() tries to set a CRAN repo for you from the R options.

shelf <- function(... cran_repo = getOption("repos") ...)

If you run getOption("repos") in RStudio you'll get the URL that you've set in RStudio's options:

> getOption("repos")

#>                     CRAN 
#> "https://cran.csiro.au/" 
#> attr(,"RStudio")
#> [1] TRUE

But if you run it in R.exe you'll get a placeholder value:

> getOption("repos")

#>                     CRAN 
#> "@CRAN@"

The R manual says that this is "a value that causes some utilities to prompt for a CRAN mirror", and indeed this is what happens in RStudio. But even if you're using RStudio to run R, there are some cases where RStudio just pipes your code into R.exe, like when you're stitching an RMarkdown document. In those cases, RStudio's defaults aren't used and so the repo URL that is passed on to shelf is shelf(..., cran_repo = "@CRAN@").

The reason you get this warning message is that Librarian does some input validation to ensure that any value provided in cran_repo is a valid URL. Since @CRAN@ is not a valid URL, it catches that, raises the warning, and defaults to https://cran.r-project.org/.

To get R.exe to stop doing this, the manual says that you'd have to set the repository yourself in a site profile or user profile with

r <- getOption("repos")
r["CRAN"] <- "http://my.local.cran"
options(repos = r)

But I think this is a drag for users, so that's why shelf catches the problem, does it for you, and lets you know about it with a warning in case you want to use a different repository instead.

I wonder if I should set a warning message specifically for this @CRAN@ issue?

@DesiQuintans DesiQuintans self-assigned this Jan 23, 2019
@jameshunterbr
Copy link
Author

jameshunterbr commented Jan 23, 2019 via email

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