1

I'm following the instructions from https://www.mssqltips.com/sqlservertip/5490/load-data-from-pdf-file-into-sql-server-2017-with-r/ to read a PDF document into SQL Server.

The problem I'm facing is when I run the code, I get the following error:

Msg 39004, Level 16, State 20, Line 5
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 5
An external script error occurred: 
Error in readRDS(pfile) : 
  cannot read workspace version 3 written by R 4.0.2; need R 3.5.0 or newer
Calls: source ... library -> find.package -> lapply -> FUN -> readRDS

Error in execution.  Check the output for more information.
Error in eval(expr, envir, enclos) : 
  Error in execution.  Check the output for more information.
Calls: source -> withVisible -> eval -> eval -> .Call
Execution halted

Any ideas what I need to do here?

Philip
  • 2,460
  • 4
  • 27
  • 52
  • When R opens it tries to open a workspace file. With the [3.5 release](https://www.r-bloggers.com/r-3-5-0-is-released-major-release-with-many-new-features/) the format of the workspace file was changed from version 2 to 3. My guess is, there is the problem. Two possible solutions: 1) update R or 2) find an '.Rdata' file and delete it. – Jan Jul 23 '20 at 06:42
  • I got the same error from readRDS(pfile) and didn't find any answers, but eventually I found out the cause of the error. The cause is that somehow my R script invoked Rscript and R from different installations. So you need to check with the which command to see if R and Rscript are from the same folder. – Shiping Mar 24 '23 at 00:35

1 Answers1

0

I think this error is due to R packages that are out of sync. I was able to fix it with update.packages().

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 12 '21 at 19:20