2

While installing mapview I get the error: namespace ‘DBI’ 0.6-1 is being loaded, but >= 0.8 is required

> install.packages("mapview")
> ... 
> Error: package or namespace load failed for ‘sf’ in loadNamespace(j <- i[[1L]], 
> c(lib.loc, .libPaths()), versionCheck = vI[[j]]):
    namespace ‘DBI’ 0.6-1 is being loaded, but >= 0.8 is required
> ...

But I have DBI v 1.0.0 installed.

> library(DBI)
> sessionInfo()
R version 3.4.4 (2018-03-15)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.5 LTS

Matrix products: default
BLAS: /usr/lib/openblas-base/libblas.so.3
LAPACK: /usr/lib/libopenblasp-r0.2.18.so

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DBI_1.0.0 sf_0.7-0 

loaded via a namespace (and not attached):
 [1] compiler_3.4.4 magrittr_1.5   class_7.3-14   tools_3.4.4    units_0.6-1    yaml_2.1.14   
 [7] Rcpp_0.12.19   grid_3.4.4     e1071_1.7-0    classInt_0.2-3 spData_0.2.9.4

I've already tried uninstalling and re-installing DBI.

What else might I try?

Rich Pauloo
  • 7,734
  • 4
  • 37
  • 69
  • 1
    Do you have more than one `.libPaths()`, and are there more than 1 DBIs? Remove the old version. E.g., `pkg = installed.packages(); sum(rownames(pkg) == "DBI")`. – Martin Morgan Oct 23 '18 at 22:54
  • Yes! There indeed is an older version of DBI. Unfortunately this is on a shared workstation, and my Sys Admin is reluctant to remove this old version of DBI because it might break the code of others. Is there a way to specify the `.libPath()` R draws dependencies from during installation? In other words, can I point R towards the updated version of DBI @ `.libPaths()[1]` in the `mapview` installation? – Rich Pauloo Oct 23 '18 at 23:13
  • 1
    There are several questions about `.libPaths` here on SO, but really just feed it the literal vector of paths you want to consider. Warning: remove the wrong one(s) and you'll be unable to do many things. – r2evans Oct 23 '18 at 23:17
  • Thanks @r2evans and @Martin Morgan. I edited my .libPaths() so that it only included the .libPath() to the updated version of DBI that the installation depends on. However, it looks like the mapview installation resets the .libPaths with `loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]):` and this reinserts the .libPath I just removed! I checked the `?install.packages` docs, and it doesn't appear that there is a way to specify the .libPath where dependencies to an installation are drawn from. Short of convincing my Sys Admin to update his version of DBI, I'm stuck! – Rich Pauloo Oct 23 '18 at 23:23
  • 1
    I think the error comes when R test loads the installation, and you can tell R not to do that via `install.packages(..., INSTALL_opts = "--no-test-load")` – Martin Morgan Oct 24 '18 at 00:34
  • Brilliant! That (along with some more finagling) did the trick @Martin Morgan. If you want to post that as an answer, I'll accept it. – Rich Pauloo Oct 24 '18 at 00:55
  • 1
    Just to clarify, DBI > 0.8 is a dependency of the sf package, not mapview. If you skip the testing this way, it may lead to unexpected behaviour when e.g. trying to read features from a database. Though, I am no expert on these things. – TimSalabim Oct 24 '18 at 06:53
  • @TimSalabim, that's correct. DBI > 0.8 is an `sf` dependency. After successfully installing `mapview`, I had to follow the error trail, and reinstall ggplot2 among other packages. Something to keep in mind when proceeding down the route suggested by @Martin Morgan, though in the end, it worked! – Rich Pauloo Oct 24 '18 at 16:44

1 Answers1

3

There are likely multiple versions of DBI installed on your system; use installed.packages() to verify this, and if possible remove all with repeated calls to remove.packages("DBI").

If one or more of the DBI packages can't be removed (e.g., in a system-wide .libPaths() location), a work-around is to install the desired package without testing that it has been installed correctly

install.packages("mapview", INSTALL_opts="--no-test-load")
Martin Morgan
  • 45,935
  • 7
  • 84
  • 112
  • This problem came up yet again in a similar context. There are multiple versions of package X on a shared computer, and using `INSTALL_opts="--no-test-load"` results in the package installing perfectly. This time the error message read: `Error: package or namespace load failed for ‘ggplot2’: .onAttach failed in attachNamespace() for 'ggplot2', details: call: NULL error: 'with_preserve_seed' is not an exported object from 'namespace:withr' Error: loading failed Execution halted` Do you have an intuitive explanation for why test loads break installation when multiple package X exist? – Rich Pauloo Nov 13 '18 at 22:59
  • 1
    @RichPauloo one source of problem is when Rprofile or Renviron (system wide or user-specific) sets `.libPaths()` to something different from the version in use at the time the package is installed, e.g., suppose `~/.Renviron` has `.libPaths("foo")` but the current session started with `R --vanilla` (hence ignoring the ~/.Renviron). – Martin Morgan Nov 19 '18 at 11:42