Re: [Rd] wishlist: better error message in R CMD check

From: Uwe Ligges <>
Date: Sun 07 Nov 2004 - 23:06:23 EST

Prof Brian Ripley wrote:

> On Sat, 6 Nov 2004, Uwe Ligges wrote:

>>Liaw, Andy wrote:
>>>I guess is that you did not try to run R CMD INSTALL before R CMD check.  R
>>>CMD check will try to install the package first (in pkg.Rcheck), and only if
>>>that's successful would checks be done.
>>>The installation process will concatenate all R files in R/ to a single file
>>>and essentially source() that in upon package loading.  That's where you
>>>would see the syntax error.  I believe the recommended way is to install the
>>>package and play with that a bit first, before doing R CMD check.  You'd
>>>find some problems are much easier to find that way (e.g., errors in

> Indeed, that is the advice: you often get much more informative error
> messages that R CMD check hides. To be explicit, install and then load
> the package and check its basic functionality before R CMD check.
> However, if you get a syntax error it is either in the NAMESPACE file or
> one of the *.R files, and sourcing all of them will rapidly find which.
>>>>From: Gabor Grothendieck
>>>>I was running R CMD check on Windows XP 2.0.1beta and 
>>>>got this:
>>>>Error in parse(file, n, text, prompt) : syntax error on 602
>>I found that syntax errors quite frequently are caused by missing 
>>newlines at the end of files.
>>What about changing the build scipts so that a newline is inserted after 
>>each of those files?

> Time to get a better editor, Uwe! Those I use do not allow you to
> save a .R file without a final NL. (I would have thought you would have
> learned not to leave an incomplete last line after being bitten a few
> times. In Emacs, set `Require Final Newline', and it's the default in
> vi.)

Well, you already know I'm using WinEdt which also saves .R files without final newline, but, e.g., Windows' native notepad.exe leaves the final line as is ...

> However, this is not done by the `build scipts' (or even scripts) but
> by tools:::.install_package_code_files() at
> if(!all(file.append(outFile, codeFiles)))
> stop("unable to write code files")
> So that is the place to alter this. There would be a small overhead both
> at INSTALL time and load time (but the latter only for packages which are
> not save-imaged or lazy-loaded), I suspect a negligible one. In any case
> file.append could be written more efficiently for this case (outFile is
> opened for each of the codeFiles) with making sure each file ended in LF
> made an option.

Have not looked that closely - I will put it on my ToDo list, but with a minor priority, i.e. it won't be done this year, if nobody else (like those bitten by the problem) is going to contribute.

Uwe mailing list Received on Sun Nov 07 23:12:18 2004

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:01:08 EST