I have a Sweave file, JMP.Rnw that inputs several other files in the same directory. The relevant excerpt from JMP.Rnw (pulling in the introduction section) is:
\SweaveInput{intro.tex}
And yet when I run Sweave from the command line, I get an error message that intro.tex cannot be found.
> Sweave("JMP.Rnw")
Error in SweaveReadFile(c(ifile, file), syntax, encoding = encoding) :
no Sweave file with name ‘./intro.tex ’ found
>
However, the file is definitely there:
$ find . -name intro.tex
./intro.tex
$
This input does seem to work for other input files, but I cannot detect a pattern that would explain why some can be imported and others cannot. There does seem to be a number of issues with Sweave and file encoding (see Sweave doesn't seem to get .Rnw file encoding right), but that doesn’t seem to be the problem here—all files are encoded in us-ascii:
$ file -bi JMP.Rnw
text/x-tex; charset=us-ascii
$ file -bi intro.tex
text/x-tex; charset=us-ascii
$
The really strange thing is that I have a separate Sweave paper setup and simply moving intro.tex to that directory and adding a \SweaveInput{intro.tex} to that master file works perfectly (i.e., builds without any issue). This other paper is using a different LaTeX template, but this would seem irrelevant since my understanding is that Sweave is basically ignoring all of this until all the code blocks are identified and executed (though my understanding here could be very wrong).
I’m running R version 2.14.2 on a x86_64-pc-linux-gnu (64-bit) machine.
Update: Investigating the answer from https://stackoverflow.com/users/210673/aaron , I found that in my alternate paper where \SweaveInput{} does work, the error message generated when I try to call a non-existent file does not contain an extra space, i.e.,
> Sweave("allocating_visibility.Rnw")
Error in SweaveReadFile(c(ifile, file), syntax, encoding = encoding) :
no Sweave file with name ‘./nothere.Rnw’ found
>
Now, I have no idea why this trailing whitespace thing is happening on one place but not another, but this does seem like the mostly likely cause of the problem.
Update II: So I think this turned out to be an encoding issue after all. When I originally created my master .Rnw file, I pasted in some text that was utf-8 encoded. I converted the file back to ascii using http://billposer.org/Software/uni2ascii.html, and still got the white space error when I ran Sweave. However, when I deleted the original \SweaveInput{} line and retyped it, the problem disappeared (i.e., it builds correctly and the extra space in the error message is gone).
I think you might have
\SweaveInput{intro.tex }instead of
\SweaveInput{intro.tex}as your error message has an extra space in it before the ending quote.
To debug, you could also edit the
SweaveReadFilecommand in theutilspackage to have it output the name of the files it’s looking for, like this.