[Bioc-devel] vignettes using foreach on Windows

Kasper Daniel Hansen kasperdanielhansen at gmail.com
Sun Mar 17 02:11:21 CET 2013

Posted here in case other people could benefit.

This is solving an issue with writing a vignette using the doParallel
backend on Windows.

If you're using foreach on Windows with the doParallel backend, the
default is to make a socket cluster (since windows don't have fork).
If you do it on a vignette, the socket cluster will open a number of
connections (default 3) which will prevent the vignette from being
build with something that looks like a latex error

Warning: running command
'"C:\PROGRA˜2\MIKTEX˜1.9\miktex\bin\texi2dvi.exe" --quiet --pdf
"bumphunter.tex"  -I
"E:/biocbld/bbs-2.12-bioc/R/share/texmf/tex/latex" -I
"E:/biocbld/bbs-2.12-bioc/R/share/texmf/bibtex/bst"' had status 1
Error in find_vignette_product(name, by = "texi2pdf", engine = engine) :
  Failed to locate the 'texi2pdf' output file (by engine
'utils::Sweave') for vignette with name 'bumphunter'. The following
files exists in directory '.': 'bumphunter-clusterplot.pdf',
'bumphunter-plotSegments.pdf', 'bumphunter.Rnw', 'bumphunter.bib',
Calls: <Anonymous> -> find_vignette_product

At first, it seems like this is solvable by just running
closeAllConnections() [ Thanks to Henrik Bengstsson ].  Unfortunately,
when the vignette is being Sweave'd, there is a sink() connection
open; closing this connection will make R CMD build exit.  The
solution is to close all socket connects, which you can do with this
Sweave chunk:


This is a cleanup step for the vignette on Windows; typically not
needed for users.

allCon <- showConnections()
socketCon <- as.integer(rownames(allCon)[allCon[, "class"] == "sockconn"])
sapply(socketCon, function(ii) close.connection(getConnection(ii)) )

More information about the Bioc-devel mailing list