70

I have been trying to create a database and installed the "DBI" package, but I am still facing this error. I reinstalled DBI and RSQLite package, but they don’t seem to work.

library("DBI")
con <- dbConnect
(RSQLite::SQLite(), dbname = ":memory:")
dbListTables(con)

Error:

Error in connection_connect(dbname, loadable.extensions, flags, vfs, extended_types) : function 'Rcpp_precious_remove' not provided by package 'Rcpp'

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Laxmi Agarwal
  • 702
  • 1
  • 4
  • 8
  • 3
    see this thread https://www.mail-archive.com/rcpp-devel@lists.r-forge.r-project.org/msg10226.html . tldr seems to be update Rcpp – user20650 Jul 17 '21 at 01:21

2 Answers2

70

I had the same problem with the packages: raster, tmap and sf. Reinstalling the package Rcpp solved the problem:

install.packages('Rcpp')
library(Rcpp)
Daniela
  • 701
  • 1
  • 3
  • 4
  • 1
    This worked for me, but I had to restart RStudio afterwards for this to take effect. – EcologyTom Oct 21 '21 at 14:25
  • Just adding some info: I had the same problem with the `mapview` package and after re-installing `Rcpp` I didn't need to load it, just `library(mapview)`. – noriega Nov 24 '21 at 19:54
48

I had the same problem with another package and the issue was that I was running a recent version of the package compiled against a previous version of Rcpp. As user20650 points out in the comment, updating Rcpp to 1.0.7 should fix it:

install.packages('Rcpp') 

In RStudio you can also use the packages panel to update the packages, as in the following image:

Enter image description here

Marcelo Avila
  • 2,314
  • 1
  • 14
  • 22
  • 4
    Well, `install.packages` didn't solve this problem in my computer, but `update.packages` did. Is there any specific reason as to why this happened? – DeBARtha Aug 07 '21 at 12:17
  • well, hard to say, since dealing with packages always involves multiple processes that might fail for different reasons. I wouldn't worry too much about it though... – Marcelo Avila Aug 07 '21 at 14:41
  • @DeBARtha Reading this I suspect that both the calling package, "DBI" in the questioners case, and "Rcpp" both needed to have been included in the install.packages operation, and if you were compiling the packages from source you might have needed to order to be Rcpp first and any dependent package to be later. Dependencies are first sought in the user's libraries, so a more recent version might exist on CRAN or Github or Rforge or BioC. Package authors should ideally include version numbers if such a dependency exists, but they might not be aware of it. – IRTFM Feb 20 '22 at 15:48