CRAN包Linux检查通过,Windows构建vignette失败求排查
Hey there, let's dig into this Windows vignette build issue you're hitting—super frustrating when Linux checks pass but Windows throws a curveball! Here's a breakdown of what might be missing and how to fix it:
1. Double-check your vignette setup in DESCRIPTION and package structure
First, confirm your vignette source files (like vignette-testme.Rmd or .Rnw) live directly in the vignettes/ folder at your package repo root—CRAN expects them here, and R CMD build might miss them if they're misplaced.
Also, make sure your DESCRIPTION file has these critical fields:
VignetteBuilder: knitr(orrmarkdown, depending on your vignette format)- Add
knitrandrmarkdownto theSuggestssection (they're required to build vignettes but don't need to be loaded with your package)
2. Use explicit flags for vignette building during package creation
Sometimes R CMD build doesn't fully bundle vignette assets by default across OSes. Try adjusting your build step to either:
- Build without pre-compiling vignettes first, then install with explicit vignette building:
# Build the package source R CMD build --no-build-vignettes xyz # Install with vignette compilation enabled R CMD INSTALL --build --install-tests xyz_version.tar.gz
Or, if you're open to using devtools for more cross-OS consistency:
devtools::build_vignettes() devtools::build()
3. Fix Git line-ending inconsistencies (a common cross-OS gotcha!)
Windows uses CRLF line endings while Linux uses LF, and Git's default settings can mangle file paths or content. Add a .gitattributes file to your repo root with these rules to enforce consistent line endings:
*.R text eol=lf *.Rmd text eol=lf vignettes/* text eol=lf
This prevents weird path parsing errors that can break file creation on Windows.
4. Verify your package archive includes all necessary files
After running R CMD build, inspect the generated .tar.gz file to confirm the vignettes/ directory is present inside it. On Linux, you can run:
tar -tzf xyz_version.tar.gz | grep vignettes
On Windows, just extract the archive and check manually. Also, double-check your .gitignore file isn't accidentally excluding the vignettes/ folder or any data/files referenced in your vignette.
5. Replicate the Windows build locally to debug permissions/paths
The error mentions a network-style path (\vf-home/home$/bs/...)—this suggests your Windows R library might be on a network share, which can cause file creation/permission issues. Try:
- Opening RStudio (or base R) as Administrator (to avoid
00LOCKdirectory permission blocks) - Changing your R library path to a local drive (like
C:/R/library) - Reinstalling the package source with explicit vignette building:
install.packages("path/to/xyz_version.tar.gz", repos = NULL, type = "source", build_vignettes = TRUE)
If this works, the original issue was likely network path-related—CRAN uses local drives for builds, so avoiding network shares in your local test environment will match their setup better.
6. Add cross-OS checks to your pre-submission workflow
To avoid this in the future:
- Use GitHub Actions or similar CI tools to run
R CMD check --as-cranon both Linux and Windows before submitting to CRAN - Or run
devtools::check_win_release()from your Linux machine to simulate the CRAN Windows build and catch errors early
The most likely culprits here are missing DESCRIPTION fields for vignette building, Git line-ending mismatches, or Windows-specific path/permission issues. Start with the DESCRIPTION and package structure checks—those are the easiest fixes!
内容的提问来源于stack exchange,提问作者Stefan Boehringer

