Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

**Installation** on Linux (Ubuntu) #150

Closed
mtennekes opened this issue Nov 7, 2017 · 19 comments
Closed

**Installation** on Linux (Ubuntu) #150

mtennekes opened this issue Nov 7, 2017 · 19 comments
Labels

Comments

@mtennekes
Copy link
Member

mtennekes commented Nov 7, 2017

I've created an installation file for Ubuntu: see https://github.com/mtennekes/tmap/tree/master/ubuntu_installation.sh

Could you check if this scripts works? If not, we can use this thread to improve it.

@larnsce
Copy link

larnsce commented Nov 15, 2017

I have followed through the installtion file, but did not manage to successfully install the tmap package. It seems as if the issue is with the rgdal package.

Beginning of Traceback error message:

installing to /home/larnsce/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

 *** caught segfault ***
address 0x1e, cause 'memory not mapped'

End of Traceback error message:

22: tools:::.test_load_package("rgdal", "/home/larnsce/R/x86_64-pc-linux-gnu-library/3.4")
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault
ERROR: loading failed
* removing ‘/home/larnsce/R/x86_64-pc-linux-gnu-library/3.4/rgdal’

My sessionInfo():

R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 17.04

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.7.0
LAPACK: /usr/lib/lapack/liblapack.so.3.7.0

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

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

other attached packages:
 [1] bindrcpp_0.2       ggalt_0.4.0        mapdata_2.2-6      maps_3.2.0         sp_1.2-5           ggmap_2.6.1        dplyr_0.7.4       
 [8] purrr_0.2.3        readr_1.1.1        tidyr_0.7.1        tibble_1.3.4       ggplot2_2.2.1.9000 tidyverse_1.1.1   

loaded via a namespace (and not attached):
 [1] reshape2_1.4.2     haven_1.1.0        lattice_0.20-35    colorspace_1.3-2   yaml_2.1.14        rlang_0.1.2        foreign_0.8-69    
 [8] glue_1.1.1         RColorBrewer_1.1-2 modelr_0.1.1       readxl_1.0.0       jpeg_0.1-8         bindr_0.1          plyr_1.8.4        
[15] stringr_1.2.0      munsell_0.4.3      gtable_0.2.0       cellranger_1.1.0   rvest_0.3.2        RgoogleMaps_1.4.1  mapproj_1.2-5     
[22] psych_1.7.5        labeling_0.3       knitr_1.17         forcats_0.2.0      extrafont_0.17     parallel_3.4.2     Rttf2pt1_1.3.4    
[29] broom_0.4.2        proto_1.0.0        Rcpp_0.12.13       KernSmooth_2.23-15 geosphere_1.5-5    scales_0.5.0.9000  jsonlite_1.5      
[36] proj4_1.0-8        mnormt_1.5-5       digest_0.6.12      rjson_0.2.15       hms_0.3            png_0.1-7          stringi_1.1.5     
[43] ash_1.0-15         grid_3.4.2         tools_3.4.2        magrittr_1.5       lazyeval_0.2.0     extrafontdb_1.0    pkgconfig_2.0.1   
[50] MASS_7.3-47        xml2_1.1.1         lubridate_1.6.0    assertthat_0.2.0   httr_1.2.1         R6_2.2.2           nlme_3.1-131      
[57] compiler_3.4.2   

Installing rgdal from source gives the following different segfault message:

 *** caught segfault ***
address 0x7fe075206833, cause 'invalid permissions'

This might be relevant:

./configure: line 2112: 21315 Aborted                 ./proj_conf_test2
checking PROJ.4: epsg found and readable... yes
./configure: line 2187: 21324 Aborted                 ./proj_conf_test3
checking PROJ.4: conus found and readable... yes

@mtennekes
Copy link
Member Author

So, the problem is the gdal library.

This post is also about rgdal and Ubuntu 17.04: https://stackoverflow.com/questions/44543935/trouble-installing-rgdal-package-on-r-3-4-in-ubuntu-17-04

@djvanderlaan Do you know if my tmap Ubuntu script (see initial post) also works on 17.04? More specifically, did you also install the dev version of gdal from the ubuntugis-unstable repository?

@djvanderlaan
Copy link

I am currently working on 17.10.

On 17.04, I used the default version of libgdal-dev to install the rgdal package. The one that ships with Ubuntu 17.04. I had no problems with that. I hadn't installed tmap, so I don't know if that worked.

I just installed tmap on ubuntu 17.10 and had to install the following packages, besides the libgdal-dev (and possible other packages) that was already installed:

sudo apt install libudunits2-dev 
sudo apt install libv8-dev 
sudo apt install libjq-dev 
sudo apt install libprotobuf-dev 
sudo apt install protobuf-compiler

So, that maps nicely with your script. I don't think it is necessary to use the ppa's, and think the default versions should work (if so, I prefer the ones that ship with ubuntu). As for the v8-dev, I would leave out the version number, as that will change.

I have no clue what causes the error message above. The session info includes a lot of attached packages. Perhaps, try with a clean R session?

@mtennekes
Copy link
Member Author

Thx! I've borrowed all the ppa's and specific version definitions from other installation procedures. It works for me with Ubuntu 16.04 Does it make sense to specify the current script for Ubuntu 16.X and yours for Ubuntu 17.X?

@djvanderlaan
Copy link

I tried your code in a ubuntu 16.04 docker container. I got it working with the following Docker script:

FROM ubuntu:16.04

RUN echo "deb http://cloud.r-project.org/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list.d/r.list \
  && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9 \
  && apt-get update && apt-get install -y \
      software-properties-common \
  && rm -rf /var/lib/apt/lists/* \
  && add-apt-repository -y ppa:ubuntugis/ubuntugis-unstable \ 
  && add-apt-repository -y ppa:opencpu/jq

RUN apt-get update && apt-get install -y \
      r-base-dev \
      libudunits2-dev libgdal-dev libgeos-dev libproj-dev \
      libv8-dev \
      libjq-dev \
      libprotobuf-dev protobuf-compiler \
  && rm -rf /var/lib/apt/lists/*


RUN echo "local({ r <- getOption('repos'); r['CRAN'] <- 'https://cloud.r-project.org'; options(repos = r)})" >> \
    /usr/lib/R/etc/Rprofile.site \
  && echo ".libPaths('/usr/local/lib/R/site-library')" >> /usr/lib/R/etc/Rprofile.site \
  && Rscript -e "install.packages('tmap')"

I don't have time to clean it up to a shell script, but I believe the main changes with your script are:

  • Make sure you add the CRAN ubuntu repo to install the latest version of R. The one that comes with ubuntu 16.04 doesn't support rgdal (I believe that is R 3.2).
  • add-apt-repository doesn't exist by default in 16.04. I had to install software-properties-common.

@ccamara
Copy link
Contributor

ccamara commented Dec 11, 2017

Using ubuntu 16.04 , can't install tmap using your script:

> library(tmap)
Error: package or namespace load failed for ‘tmap’ in dyn.load(file, DLLpath = DLLpath, ...):
 unable to load shared object '/home/ccamara/R/x86_64-pc-linux-gnu-library/3.4/sf/libs/sf.so':
  liblwgeom-2.3.so.0: no se puede abrir el archivo del objeto compartido: No existe el archivo o el directorio

which translates into something like liblwgeom-2.3.so.0: can't find shared object file: Folder or file do not exist

don't know if it helps, but some days ago, rgdal was updated to 2.2.1 and broke my previously working tmap installation (as well as my qgis installation too, but I'm afraid that's another topic).

@bczernecki
Copy link

bczernecki commented Dec 12, 2017

@ccamara : I had this same issue so I decided to manually install liblwgeom-2.3 (together with liblwgeom-dev). This line should solve this issue:

sudo apt-get install liblwgeom-2.3-0

@ccamara
Copy link
Contributor

ccamara commented Dec 13, 2017

I can confirm that adding this line tmap is installed perfectly on ubuntu 16.04 LTR

@ElPaDe
Copy link

ElPaDe commented Feb 26, 2018

I had tmaps running on Ubuntu 17.04, but could not make it runon Ubuntu 17.10. All Ubuntu-packages you recommend were installed, but I kept getting the following error for install.packages('tmaps'):

* installing *source* package ‘tmap’ ...
** package ‘tmap’ successfully unpacked and MD5 sums checked
** R
** data
** inst
** preparing package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/usr/local/lib/R/site-library/sf/libs/sf.so':
  /usr/local/lib/R/site-library/sf/libs/sf.so: undefined symbol: _ZN17GDALDriverManager14GetDriverCountEv
ERROR: lazy loading failed for package ‘tmap’
* removing ‘/usr/local/lib/R/site-library/tmap’
* restoring previous ‘/usr/local/lib/R/site-library/tmap’

My solution might be obvious, but kept me searching for long time:
install.packages('sf') install.packages('tmap')
Now is runs.

HTH

@larnsce
Copy link

larnsce commented Apr 5, 2018

I have moved on to Ubuntu 17.10. but still can't get tmap installed. I have once more installed all packages as listed here before trying to install tmap. The problem still seems to be with the rgdal package,

Traceback error message:

installing to /home/larnsce/R/x86_64-pc-linux-gnu-library/3.4/rgdal/libs
** R
** data
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

 *** caught segfault ***
address 0x21000018, cause 'memory not mapped'

Traceback:
 1: .Call("PROJ4_proj_def_dat_Installed", PACKAGE = "rgdal")
 2: assign("has_proj_def.dat", .Call("PROJ4_proj_def_dat_Installed",     PACKAGE = "rgdal"), envir = .RGDAL_CACHE)
 3: fun(libname, pkgname)
 4: doTryCatch(return(expr), name, parentenv, handler)
 5: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 6: tryCatchList(expr, classes, parentenv, handlers)
 7: tryCatch(fun(libname, pkgname), error = identity)
 8: runHook(".onLoad", env, package.lib, package)
 9: loadNamespace(package, lib.loc)
10: doTryCatch(return(expr), name, parentenv, handler)
11: tryCatchOne(expr, names, parentenv, handlers[[1L]])
12: tryCatchList(expr, classes, parentenv, handlers)
13: tryCatch({    attr(package, "LibPath") <- which.lib.loc    ns <- loadNamespace(package, lib.loc)    env <- attachNamespace(ns, pos = pos, deps)}, error = function(e) {    P <- if (!is.null(cc <- conditionCall(e)))         paste(" in", deparse(cc)[1L])    else ""    msg <- gettextf("package or namespace load failed for %s%s:\n %s",         sQuote(package), P, conditionMessage(e))    if (logical.return)         message(paste("Error:", msg), domain = NA)    else stop(msg, call. = FALSE, domain = NA)})
14: library(pkg_name, lib.loc = lib, character.only = TRUE, logical.return = TRUE)
15: withCallingHandlers(expr, packageStartupMessage = function(c) invokeRestart("muffleMessage"))
16: suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE))
17: doTryCatch(return(expr), name, parentenv, handler)
18: tryCatchOne(expr, names, parentenv, handlers[[1L]])
19: tryCatchList(expr, classes, parentenv, handlers)
20: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call)[1L]        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        msg <- conditionMessage(e)        sm <- strsplit(msg, "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && identical(getOption("show.error.messages"),         TRUE)) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
21: try(suppressPackageStartupMessages(library(pkg_name, lib.loc = lib,     character.only = TRUE, logical.return = TRUE)))
22: tools:::.test_load_package("rgdal", "/home/larnsce/R/x86_64-pc-linux-gnu-library/3.4")
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault

Session info

sessionInfo()

R version 3.4.3 (2017-11-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 17.10

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

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

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

loaded via a namespace (and not attached):
[1] compiler_3.4.3 tools_3.4.3    yaml_2.1.18 

@Nowosad Nowosad closed this as completed May 1, 2018
@mtennekes mtennekes reopened this Aug 8, 2018
@Nowosad Nowosad pinned this issue Mar 9, 2019
@SteadyGiant
Copy link

Here's one. I shortened the output message.

> install.packages('tmap')

Installing package into ‘/home/evroot/R/x86_64-pc-linux-gnu-library/3.6’
(as ‘lib’ is unspecified)
** byte-compile and prepare package for lazy loading
Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/evroot/R/x86_64-pc-linux-gnu-library/3.6/lwgeom/libs/lwgeom.so':
  libproj.so.13: cannot open shared object file: No such file or directory
Calls: <Anonymous> ... asNamespace -> loadNamespace -> library.dynam -> dyn.load
Execution halted
Warning in install.packages :
  installation of package ‘tmap’ had non-zero exit status

I'm using Kubuntu 18.04.3. I already have all packages in the installation script installed. I'm able to install and load the sf R package with no issues:

>library(sf)

Linking to GEOS 3.8.0, GDAL 3.0.2, PROJ 6.2.1

Session info:

R version 3.6.2 (2019-12-12)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.3 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

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] shiny_1.4.0 sf_0.8-1   

loaded via a namespace (and not attached):
 [1] xfun_0.12          remotes_2.1.0      testthat_2.3.1     usethis_1.5.1     
 [5] miniUI_0.1.1.1     htmltools_0.4.0    rlang_0.4.4        pkgbuild_1.0.6    
 [9] e1071_1.7-3        later_1.0.0        glue_1.3.1         withr_2.1.2       
[13] DBI_1.1.0          sessioninfo_1.1.1  devtools_2.2.1     evaluate_0.14     
[17] memoise_1.1.0      knitr_1.27         callr_3.4.1        fastmap_1.0.1     
[21] httpuv_1.5.2       ps_1.3.0           class_7.3-15       fansi_0.4.1       
[25] Rcpp_1.0.3         clipr_0.7.0        KernSmooth_2.23-16 xtable_1.8-4      
[29] promises_1.1.0     backports_1.1.5    classInt_0.4-2     desc_1.2.0        
[33] pkgload_1.0.2      jsonlite_1.6       mime_0.8           fs_1.3.1          
[37] digest_0.6.23      processx_3.4.1     grid_3.6.2         rprojroot_1.3-2   
[41] cli_2.0.1          tools_3.6.2        magrittr_1.5       whisker_0.4       
[45] crayon_1.3.4       ellipsis_0.3.0     prettyunits_1.1.1  reprex_0.3.0      
[49] assertthat_0.2.1   rmarkdown_2.1      rstudioapi_0.10    R6_2.4.1          
[53] units_0.6-5        compiler_3.6.2

@mtennekes
Copy link
Member Author

Please check installation of lwgeom

@SteadyGiant
Copy link

I installed the lwgeom R package and that fixed it. I could then install tmap. Thank you.

@Nowosad
Copy link
Member

Nowosad commented Apr 26, 2020

@mtennekes the link in the first post is broken

@darribas
Copy link

Apologies if this is an obvious question, but I'm having trouble installing tmap on R 3.6 since it appears to depend on XML, which now requires R 4.0. Is there any way around that does not involve jumping to 4.0? Thanks very much!!!

@Robinlovelace
Copy link
Collaborator

@darribas try:

remotes::install_version(package = "XML", version = "3.99-0.3")

@darribas
Copy link

In the end I did not try this approach @Robinlovelace and instead followed your advice to jump on 4.0. I swapped the branch for the install and now it all works again. Working code available at:

https://github.com/darribas/gds_env/blob/f99990475f991aeb07dc8176c62ef3f9a3d9cd46/Dockerfile

@Robinlovelace
Copy link
Collaborator

Great to see @darribas, thanks for sharing.

@Robinlovelace
Copy link
Collaborator

Pretty sure this issue is well-and-truly fixed with most people upgrading to R 4.0.0 or more recent versions of Linux distros such as Ubuntu 20.04, so taking the liberty of closing this - lack of activity also. Amazing work @mtennekes, loving your package for my work atm:

image

@mtennekes mtennekes unpinned this issue Dec 16, 2020
@mtennekes mtennekes pinned this issue Dec 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

10 participants