Rstudio project could not be opened…file line number 3 is invalid

Hello everyone,

I have taken my notes on codes on R project however now I cannot open the project anymore as it keeps giving me the error about 'line number 3 being invalid'. Does anybody know how I can solve this and access my notes on the R file?

The project: https://rstudio.cloud/project/626879
The error: image

1 Like

You could be able to open that .Rproj file with a text editor.

If you open it with a text editor, what are the contents? Is it possible that file became corrupt, somehow?

1 Like

I have a similar issue as the OP for a long used project which recently started throwing this error:
"Project '~/filepath/filename.Rproj' could not be opened: file line number 1 is invalid"

I was able to open the .Rproj file with Notepad ++ and it showed a single line (218 characters) of all 'NUL' (Ascii code 0 from what I can gather from the internet). Looking at other .Rproj files, the 'NUL' is different and, I assume, not good.

Looking at other .Rproj files, generally they all seem to have the same information on my machine:
"Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX
"
With slight variation if its was related to a R package.

I was able to copy and paste the text from another .Rproj file into the corrupt .Rproj file and the project will open now.
Hopefully this will generally help.

2 Likes

Yep, I could recover the code, thank you.

It is strange why it would not open up and cannot see any reasons why it must've gotten corrput.

Thank you for the detailed info and sharing the exprience, hopefully I'll learn what caused the file to become corrupt and resolve it for future projects.

It'd be helpful if we could figure out what is causing this file corruption.

Is there anything unique about the projects you're working in? Is the folder managed by e.g. Dropbox, Onedrive, or a similar cloud synchronization tool?

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.