5

I updated my GDAL to 2.2.2 on Ubuntu and now rgdal fails in R. I get this message when I try to load rgdal (I also tried to update rgdal, but didn't work).

Error in get(method, envir = home) : 
  lazy-load database '/home/R/x86_64-pc-linux-gnu-library/3.3/rgdal/R/rgdal.rdb' is corrupt
In addition: Warning messages:
1: In .registerS3method(fin[i, 1], fin[i, 2], fin[i, 3], fin[i, 4],  :
  restarting interrupted promise evaluation
2: In get(method, envir = home) :
  restarting interrupted promise evaluation
3: In get(method, envir = home) : internal error -3 in R_decompress1
Error: package or namespace load failed for ‘rgdal’

Any ideas of how to fix this?

user13317
  • 451
  • 3
  • 13
  • Have you tried re-installing `rgdal`? – Tung Apr 13 '18 at 16:18
  • @Tung Yes, I tried to re-install `rgdal`, but it did nothing. I fixed the issue by just updating the headers. – user13317 Apr 13 '18 at 16:21
  • Did you fix it? Please add your solution as answer! – Ott Toomet Apr 13 '18 at 17:11
  • @ott-toomet I don't think I can answer, I don't see a link to do so anyways. I ran this `sudo add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable && sudo apt update && sudo apt upgrade` Although, now I'm getting errors I never got before, ugh... I'm getting an error that my proj4string is not valid, which never happened in the past and that works in QGIS. – user13317 Apr 13 '18 at 17:27
  • OK, so it's more like a hack that works. – Ott Toomet Apr 13 '18 at 17:29

4 Answers4

2

I was able to resolve this issue by deleting my corrupt rgdal installation, and simply reinstalling.

The warning message should indicate where it the folder is located (in your case /home/R/x86_64-pc-linux-gnu-library/3.3/rgdal)

In your terminal, you can delete the installed version with

rm -rf path/to/rgdal

where path/to/rgdal will be specific to your system and version. Then reinstall in R with install.packages('rgdal')

0

I resolve it by updating and upgrading my system :

sudo apt update & sudo apt upgrade
Elite
  • 5
  • 5
0

This worked for me:

remove.packages("rgdal")
install.packages("rgdal")
library(rgdal)
SophiaL
  • 61
  • 7
0

What worked for me

  1. Open terminal
  2. Run brew install gdal (this step may take a few minutes)
  • Note: After step 2, it may give an error if you already had it installed (that happened to me). If you get this error, run brew upgrade gdal (may take a few more minutes)
  1. Reinstall rgdal from source, with:
install.packages("rgdal", repos = NULL, type="source")
  1. Restart your R session (i.e. close and reopen RStudio) - you cannot skip this step

Now try library(rgdal) - it should succeed!

Other things to try

If the above steps don't work, try any of the following:

  • Download the rgdal package source and compiling manually by going to CRAN and downloading the source (click on the link outlined here), then install by running install.packages("path/to/downloaded/file/rgdal_1.5-23.tar.gz", repos = NULL, type="source")
    • Close and reopen RStudio and that may help
  • Also worth trying to manually delete the corrupted file (e.g. with rm /Users/$USER/Library/R/4.0/library/rgdal/R/rgdal.rdb), then running install.packages("rgdal", repos = NULL, type="source"), closing and reopening RStudio.
  • If all of that doesn't work, one last thing is to try install.packages("rgdal", repos="https://mac.R-project.org"), close and reopen RStudio, and hopefully library(rgdal) succeeds.

Hope some of these notes helps someone else with this problem!

stevec
  • 41,291
  • 27
  • 223
  • 311