Loading R packages not working anymore after updating R

For a while, I had been calling R functionalities from my Julia code successfully with package RCall. Recently, however, I updated the version of my R installation, and now it seems the Julia code is broken. I should say that I’m using VSCode to run the .jl file, and the attached R’s version is the same as my latest installation of R.

When I run the following lines:

using RCall
R"""
    library(forecast)
"""

I get the following error message:

ERROR: REvalError: Warning: package ‘forecast’ was built under R version 4.3.3
Error: package or namespace load failed for ‘forecast’ in inDL(x, as.logical(local), as.logical(now), …):
unable to load shared object ‘C:/Users/----/Documents/R/win-library/4.1/rlang/libs/x64/rlang.dll’:
LoadLibrary failure: The specified procedure could not be found.

The thing is, I have installed package forecast under R version 4.3.3. If I call the package from the R GUI, it works fine. I guess it might a problem with VSCode not “finding” whatever it has to find to make it work. I should add that I have added the path to R’s exe file to the ‘User Settings’ in VSCode’s JSON file.

Anyone know how to solve this? Thank you in advance.

I find this:

https://www.reddit.com/r/RStudio/comments/1azh8xf/if_i_update_r_does_it_replace_the_old_r_version/

An upgrade to 4.4 will make a new install of R which RStudio will use by default and you’ll need to reinstall all your packages.

It seems like an R problem, on that side, and would be independently of if not use from Julia or other language. I’m no R expert, I guess 4.4 may be consider a major upgrade (and/or requiring recompilation of R packages, because of breaking API? Maybe that’s it, why reinstall needed, since might as well if potentially incompatible), not just if first digit changes, and I’m not sure when that last happened. Might be rare.

Consider also the path - C:/Users/----/Documents/R/win-library/4.1/rlang/libs/x64/rlang.dll implies Julia is loading R 4.1, not R 4.3, which may be the issue. Take a look at Installation · RCall.jl and see if setting the preference to your known good R path helps!

2 Likes