Search code examples
rdevtoolsr-package

devtools Error in read.dcf(path_desc) : Line starting 'This corresponds to ...' is malformed


I've spent long enough on this problem that I thought I'd make a post about it.

Using devtools to develop R packages is really a must. I generated my new package with the usual command :

usethis::create_package(proj_path) 

Then I started working on the contents. Editing the DESCRIPTION file, adding R code in the R/ folder and documenting with Roxygen.

Once I had some basic things put down, I wanted to check my work by documenting/building the package so I ran

devtools::document(proj_path)

and got the following error

Error in read.dcf(path_desc) : Line starting 'This corresponds to ...' is malformed!

That's it, no info on what caused the error.

I never wrote anything even close to "This corresponds to" in my doc. The closest thing to this error I found is this issue on github, which has the same type of Error in read.dcf( idea, but this did not help my case.


Solution

  • The clue to this error is in the desc part of the Error in read.dcf(path_desc). This alludes to the DESCRIPTION file of the package.

    When I substituted the DESCRIPTION file for a brand new template one, the package compiled fine. Specifically, my issue came from the "Description" field of the file.

    I forgot a tabulation when inserting a new line. The erroneous file read:

    Description: blabla
    blabla
    

    Adding the tabulation like so:

    Description: blabla
       blabla
    

    fixes the problem.