[R-pkg-devel] corrupted NAMESPACE file

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Fri Jan 20 18:38:51 CET 2023


On 20/01/2023 12:15 p.m., Spencer Graves wrote:
> Hi, Ivan and Uwe:
> 
> 
> 	  Thanks for your suggestions, but I've so far been unable to get them
> to work.  see below.
> 
> 
> On 1/20/23 9:22 AM, Uwe Ligges wrote:
>>
>>
>> On 20.01.2023 15:53, Ivan Krylov wrote:
>>> В Fri, 20 Jan 2023 08:41:25 -0600
>>> Spencer Graves <spencer.graves using effectivedefense.org> пишет:
>>>
>>>> ** byte-compile and prepare package for lazy loading
>>>> Error in parse(nsFile, keep.source = FALSE, srcfile = NULL) :
>>>>      1:1: unexpected input
>>>
>>> tools::showNonASCIIfile('https://raw.githubusercontent.com/JamesRamsay5/fda/master/NAMESPACE')
>>> # 1: <ef><bb><bf>export(AmpPhaseDecomp,
>>>
>>> Your NAMESPACE file starts with a U+FEFF ZERO WIDTH NO-BREAK SPACE.
>>> You'll need to remove it, e.g. by re-creating the first line.
>>
>>
>> Note that this is also called "byte order mark" (BOM). Tell your editor
>> not to create files with BOM.
>>
>> You can also fix in R:
>>
>> x <- readLines(..., encoding="UTF-8-BOM")
>> writeLines(x, ......)
> 
> 
> 	  In RStudio 2022.12.0+353 (the current version),
> 
> 
> tools::showNonASCIIfile('https://raw.githubusercontent.com/JamesRamsay5/fda/master/NAMESPACE')
> 
> 
> returned "char(0)".  'readLines' and 'writeLines' as Uwe suggested
> failed to fix it for me.
> 
> 
> 	  The first problem I noticed with this was that RStudio could not read
> the NAMESPACE file.  When I tried, it said, "File is binary rather than
> text so cannot be opened by the source editor."  I changed something
> using a different editor and did "git commit" and "git push", and got
> the error on GitHub that I reported above.  I copied the file elsewhere,
> deleted it locally and from GitHub, then recreated it in LibreOffice by
> manually typing the first and last lines then copying the rest from a
> copy I had saved elsewhere.  The RStudio would open the file, but I
> still get the same error message as above from both "R CMD build fda"
> locally and from GitHub Action at:
> 
> 
> https://github.com/JamesRamsay5/fda
> 
> 
> 	  Other suggestions?

I think Uwe's suggestion was to check out the file, apply his two steps, 
and commit it again.  Your showNonASCIIfile() call was trying to work on 
something else.  Maybe your other commands were too?

Another possibility is to roll back all your changes to that file until 
you have a copy you can work with.  I think commit ab455089 is probably 
the bad one; Github shows invisible changes to the first line.  You 
don't want those.

Duncan Murdoch



More information about the R-package-devel mailing list