NOTE in R CRAN Check: No repository set, so cyclic dependency check skipped
Asked Answered
N

2

37

As of R 3.1.0 I get the following R check:

* checking package dependencies ... NOTE
  No repository set, so cyclic dependency check skipped

I tried this advice: https://twitter.com/phylorich/status/431911660698083328

No go. I put the line options(repos="http://cran.rstudio.com/") in a .Rprofile in the package root directory. Still get the Note.

Also section 1.3.1 of Writing R Extensions states:

Some Windows users may need to set environment variable R_WIN_NO_JUNCTIONS 
to a non-empty value. The test of cyclic declarations33in DESCRIPTION 
files needs repositories (including CRAN) set: do this in ~/.Rprofile.

Is this possibly a result of the set environment variable R_WIN_NO_JUNCTIONS? If so how can I go about doing this? Any other possible causes of the note or suggested fixes?

Negro answered 19/4, 2014 at 1:58 Comment(7)
You say you have a .Rprofile in the package's root directory - are you setting the repos option from the .Rprofile in your home directory? You can check which that is by running Sys.getenv("R_USER")Weissman
@Weissman I threw a .Rprofile in my home directory with the options setting a repos. THis gets rid of the NOTE. Can you throw that down as an answer? Is there a way to set the repos w/o having to put a .Rprofile in my home dir, that is set something up within the package directory that will set the repos?Negro
An environment variable for repos would be nice.Alesiaalessandra
Adding an repos with options in my .Rprofile doesn't correct this for me (when checking with devtools::check())...Cussed
I created a file file.create(".Rprofile") in Sys.getenv("R_USER") this directory and added a line to it cat("options(repos = c(CRAN=\"http://cran.r-project.org\"))", file = ".Rprofile") but it did not solve the problem.Hughett
@MarcinKosinski Actually physically (not programatically) make a file in the root directory called .Rprofile. Add the line options(repos = c(CRAN=\"http://cran.r-project.org\"). Run the checks.Negro
That should be options(repos = c(CRAN="http://cran.r-project.org"))Negro
F
21

From Writing R Extensions

The test of cyclic declarations in DESCRIPTION files needs repositories (including CRAN) set: do this in ~/.Rprofile, by e.g

options(repos = c(CRAN="http://cran.r-project.org"))

Recommended

User should double check if his .Rprofile is in his home and that it contains the mentioned option.

# in R session (any platform)
# where is my profile?
file.path(Sys.glob("~"),".Rprofile")
# is it there?
file.exists(file.path(Sys.glob("~"),".Rprofile"))

Or from R session using extra package:

library(pathological)
r_profile()

User should double check if the option entry is not nested in the IF condition, like in the following code:

# this will not help for R CMD check --as-cran
if(interactive()) {
options(repos = c(CRAN="http://cran.r-project.org"))
}

Dry run for any platform

Here is R script preparing easy temporary case of R package for testing, helping to faster find what is going wrong in your local usage. This aproach helped myself to locate what was wrong in my .Rprofile file and generally can help to set up working initial state. In best case, the check run should show only 1 NOTE about new submission.

  1. first copy/paste the code and source it in your R session (--vanilla preferably)
  2. then run the command printed by the script to check test case --as-cran.

Example

# for example
R --vanilla -f makePackage.R
# here the resulting package path is as below
R --no-site-file CMD check --as-cran /tmp/pkgtest
# now see the check log

If your .Rprofile does not exist it will be created and one new line placed at the end of file in any case.

The makePackage.R script

# makePackage.R
# makes simple package for playing with check --as-cran

# copy this content to file makePackage.R
# then source it into your R --vanilla session

name <- "pkgtest"

#
# prepare and adjust package template
#

tempbase <- dirname(tempdir())
e <- new.env()
path <- dirname(tempdir())

# make simple package in path
e$fu <-  function(){"Hello"}
package.skeleton(name=name,force=T,path=path,environment=e)
nil <- file.remove(
    file.path(path,name,'Read-and-delete-me'),
    file.path(path,name,'man',paste0(name,'-package.Rd'))
    )

# adjust DESCRIPTION
D <- readLines(file.path(path,name,"DESCRIPTION"))
D[grepl("^Title: ",D)] <- "Title: Testing Skeleton"
D[grepl("^Author: ",D)] <- "Author: John Doe"
D[grepl("^Description: ",D)] <- "Description: Checking --as-cran check."
D[grepl("^Maintainer: ",D)] <- "Maintainer: John Doe <[email protected]>"
D[grepl("^License: ",D)] <- "License: GPL (>= 2)"
write(D,file.path(path,name,"DESCRIPTION"))

# make fu.Rd
write(
"\\name{fu}\\alias{fu}\\title{Prints}\\description{Prints}
\\usage{fu()}\\examples{fu()}",
file.path(path,name,'man','fu.Rd'))

#
# ensure that .Rprofile contains repos option 
# add fresh new line et the end of .Rprofile
# 

userRp <- file.path(Sys.glob("~"),".Rprofile")
write("options(repos = c(CRAN='http://cran.r-project.org'))",file=userRp, append=TRUE)

#
# print final message
#

msg <- sprintf("
Your test package was created in %s,
under name %s,
your user .Rprofile in %s was modified (option repos),
now check this test package from command line by command:

R --no-site-file CMD check --as-cran %s
", path, name,  userRp, file.path(path,name) 
)

# now is time to check the skeleton
message(msg)

Checking the package

# replace package-path by the path adviced by the sourcing the script above
R --no-site-file CMD check --as-cran package-path

There is user profile and site profile, in the approach above you bypasses site profile (in second step) by using --no-site-file option for package skeleton option.

PDF errors

You can experience PDF and latex related errors, caused very likely by missing or not complete latex instalation. Ycan use --no-manual option to skip PDF tests.

R --no-site-file CMD check --no-manual --as-cran /tmp/pkgtest
Fifi answered 30/7, 2014 at 17:21 Comment(1)
This has also worked on Mac OS X. To have only 1 error: (1) Remove the dot in the Title (2) Change the date to your current date. In my case I had to install MacTex, (probably for another issue) that I did from here: tug.org/mactex/mactex-download.htmlRetention
K
6

The answer above only works for Linux. On Windows I had to use a different method. When I tried to build and check my new package in R 3.2.0 on Windows 7, I got the same error:

checking package dependencies ... NOTE
No repository set, so cyclic dependency check skipped

I tried creating a file .Rprofile in my new package's root directory, but that didn't work. Instead I had to go to:

C:\Program Files\R\R-3.2.0\etc

and edit the file:

Rprofile.site

In the Rprofile.site file I added the suggested line:

options(repos = c(CRAN="http://cran.r-project.org"))

After I edited the Rprofile.site file, the NOTE "No repository set, so cyclic dependency check skipped" finally disappeared.

Kunkel answered 29/4, 2015 at 5:11 Comment(2)
My comment says "home directory", in this case that happens to be your home directory. It's typically in the directory where your package will be built and the tarball will output to.Negro
I get "Access Denied" when trying to adapt Rprofile.siteElviaelvie

© 2022 - 2024 — McMap. All rights reserved.