From ligges at statistik.uni-dortmund.de  Sun Nov  7 13:06:23 2004
From: ligges at statistik.uni-dortmund.de (Uwe Ligges)
Date: Sun Nov  7 13:06:07 2004
Subject: [Rd] wishlist: better error message in R CMD check
In-Reply-To: <Pine.LNX.4.44.0411061427080.26999-100000@gannet.stats>
References: <Pine.LNX.4.44.0411061427080.26999-100000@gannet.stats>
Message-ID: <418E0FBF.5000504@statistik.uni-dortmund.de>

Prof Brian Ripley wrote:

> On Sat, 6 Nov 2004, Uwe Ligges wrote:
> 
> 
>>Liaw, Andy wrote:
>>
>>
>>>Gabor,
>>>
>>>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
>>>NAMESPACE).
> 
> 
> 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


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