1

I'm updating a package that is currently on CRAN. Running devtools::check() locally consistently gives the WARNING

> checking package subdirectories ... WARNING
  Found the following directory with the name of a version control directory:
  These should not be in a package tarball.
    ./.git

and NOTE

> checking for hidden files and directories ... NOTE
  Found the following hidden files and directories:
    .git
  These were most likely included in error. See section 'Package
  structure' in the 'Writing R Extensions' manual.
  
  CRAN-pack does not know about
    .git

When I check on winbuilder, I no longer get the WARNING, but I do get the NOTE.

This is my .Rbuildignore file, which should be ignoring the .git folder, but isn't for some reason (?)

^.*\.Rproj$
^\.Rproj\.user$
^cran-comments\.md$
^\.Rhistory$
^docs$
^\.travis\.yml$
^CRAN-RELEASE$
^\.git$
^\.github$

I recently migrated from Windows to Mac (os 12.1), and I'm running R version 4.1.1 and RStudio version 1.4.1717. Thanks for any help - I can't figure this one out, and it's making me crazy.


EDIT: For reproducibility, my package is currently on Github at https://github.com/mbtyers/riverdist

torek
  • 448,244
  • 59
  • 642
  • 775
Matt Tyers
  • 2,125
  • 1
  • 14
  • 23
  • Stab in the dark, but have you converted the line endings in your `.Rbuildignore` from Windows to Mac line endings? – Hobo Jan 02 '22 at 11:11
  • @Hobo This sounds promising - what are Mac line endings? – Matt Tyers Jan 02 '22 at 11:16
  • What happens if you just ignore with `.git`? It seems to work on my build ignores. – NelsonGon Jan 02 '22 at 12:49
  • @NelsonGon My Buildignore includes `^\.git$`, is that what you meant? – Matt Tyers Jan 02 '22 at 13:19
  • I meant change the regex to just `.git` and `.github`. This would ignore the entire dir? – NelsonGon Jan 02 '22 at 13:20
  • 2
    @NelsonGon No luck with `.git`, `^\.git`, `^git`, or `^git$`. `^\git$` throws an error when I Install & Restart, which is encouraging since it was starting to think my buildignore was being ignored entirely! – Matt Tyers Jan 02 '22 at 14:19
  • @MattTyers - sorry, I went to bed after posting that, and haven't looked until now. I don't have a Mac to test, but Windows uses two characters (`\r\n`) to signify the end of a line. Mac, being unix-based, just uses `\n`. Have a look at this question: https://stackoverflow.com/q/6373888 for details, including conversion. The easiest way will be to use the `dos2unix` command-line utility, if you have it or can install it. This question: https://stackoverflow.com/q/3569997 might help too – Hobo Jan 03 '22 at 02:02

2 Answers2

2

Edited to simplify:

You can leave .git out of .Rbuildignore completely: version control directories are automatically ignored for several version control systems, including git.

user2554330
  • 37,248
  • 4
  • 43
  • 90
  • Thanks for your answer - unfortunately, neither suggestion (removing the `.git` line completely or turning it into `^\.git`) made the WARNING or NOTE go away. Trying winbuilder, I still have the NOTE. – Matt Tyers Jan 02 '22 at 14:23
  • Is your package on Github? We can't reproduce the issue with what you've posted. – user2554330 Jan 02 '22 at 14:48
  • Also: you haven't told us how you built the tarball. Do you get the problem if you build it from the command line using `R CMD build`? – user2554330 Jan 02 '22 at 14:50
  • Good suggestion with the Github link - see edit above. So far I've built the tarball using the "Install & Restart" button in RStudio. – Matt Tyers Jan 02 '22 at 15:52
  • I think the problem may be that "Install & Restart" *doesn't* build a tarball, it just installs locally. You've probably been submitting an unmodified tarball after each attempted change. To get RStudio to build a tarball, use "Build Source Package" in the "Build | More..." menu. – user2554330 Jan 02 '22 at 16:22
  • When I do "Build Source Package" on a checked out copy of your repos, I don't get any .git files in the tarball. – user2554330 Jan 02 '22 at 16:24
  • Found a solution (below). Thanks again for your help - I learned some new things from your answer & comments, even if it turned out to be something else! – Matt Tyers Jan 05 '22 at 08:52
1

This one had a strange and unrelated solution, which I will post in case someone else runs into a similar issue. I should have seen the clue when I ran "build source package" (ordevtools::build() or devtools::check()) and in the long scrolling output would get a long series of

rm: /var/folders/1r/qj42pgb ... 3c4f: Operation not permitted
rm: /var/folders/1r/qj42pgb ... b6ad: Operation not permitted
rm: /var/folders/1r/qj42pgb ... s/e3: Directory not empty
rm: /var/folders/1r/qj42pgb ... c5d0: Operation not permitted

My guess is that when I transferred my work from a Windows machine to a Mac via external drive, some directory was corrupted or there was a permissions issue. If so, I could imagine my machine being unable to follow my .Rbuildignore, or exclude version control directories as mentioned in @user2554330's answer.

Ultimately, I downloaded a fresh version from Github (which I had been pushing to) and built/checked on that, and the issue was gone.

Matt Tyers
  • 2,125
  • 1
  • 14
  • 23