sqlrdata.tableexternal-scriptudpipe

R Udpipe package install into SQL Server error


I get the following error when I try to run UDPIPE via external script call in SQL Server.

Msg 39004, Level 16, State 20, Line 31
A 'R' script error occurred during execution of 'sp_execute_external_script' with HRESULT 0x80004004.
Msg 39019, Level 16, State 2, Line 31
An external script error occurred: 
Error: package or namespace load failed for 'udpipe':
 object 'as.xts' not found whilst loading namespace 'data.table'
In addition: Warning message:
package 'udpipe' was built under R version 4.1.0 

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

I normally install packages by installing them directly into R (version 4.1) then copy them to my SQL Server R library directory. It's worked fine for all other packages, but UDPIPE throws this error, and googling hasn't found a solution.

Note: Udpipe and data.table work fine in the R standalone.

Any help would be very appreciated.

(I'm running SQL Server 2019 and upgraded R to 4.1, which matches my R standalone).


Solution

  • Thank you for the guidance. Yes you were correct. It does seem to be the result of installing packages that were built for the wrong version of R. Alas, removing and re-installing packages doesnt quite fix it, as there seems to be a lot of "stuff" left over wreaking havoc.

    For anyone that lands here in the future: The solution in the end was to uninstall R services using the SQL 2019 setup tool. Then re-install R services. And finally install a clean R 3.5.2 instance, install all needed R packages there, and copy over to the SQL R Library.

    That seems to cleanup all the bits that were "corrupted" for lack of a better term.