r-transit / tidytransit

R package for working with GTFS data
https://r-transit.github.io/tidytransit/
150 stars 22 forks source link

Problem when installing tidytransit #208

Closed temospena closed 1 year ago

temospena commented 1 year ago

Hi,

I am having this odd error when installing tidy transit:

> install.packages("tidytransit")
Installing package into ‘/home/XXX/R/x86_64-pc-linux-gnu-library/4.3’ 
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/tidytransit_1.6.0.tar.gz'
Content type 'application/x-gzip' length 4622867 bytes (4.4 MB)
==================================================
downloaded 4.4 MB

* installing *source* package ‘tidytransit’ ...
** package ‘tidytransit’ successfully unpacked and MD5 sums checked
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading
free(): invalid pointer
Aborted (core dumped)
ERROR: lazy loading failed for package ‘tidytransit’
* removing ‘/home/XXX/R/x86_64-pc-linux-gnu-library/4.3/tidytransit’
Warning in install.packages :
  installation of package ‘tidytransit’ had non-zero exit status

The downloaded source packages are in
    ‘/tmp/Rtmp0Lhihz/downloaded_packages’

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 22.04.3 LTS

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

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

time zone: Europe/Lisbon
tzcode source: system (glibc)

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

other attached packages:
[1] shiny_1.7.5.1

loaded via a namespace (and not attached):
 [1] jsonlite_1.8.7    miniUI_0.1.1.1    compiler_4.3.1    promises_1.2.1    reprex_2.0.2      Rcpp_1.0.11      
 [7] clipr_0.8.0       jquerylib_0.1.4   callr_3.7.3       later_1.3.1       yaml_2.3.7        fastmap_1.1.1    
[13] mime_0.12         R6_2.5.1          knitr_1.44        tibble_3.2.1      R.cache_0.16.0    bslib_0.5.1      
[19] pillar_1.9.0      R.utils_2.12.2    rlang_1.1.1       utf8_1.2.4        cachem_1.0.8      httpuv_1.6.12    
[25] xfun_0.40         sass_0.4.7        fs_1.6.3          memoise_2.0.1     cli_3.6.1         withr_2.5.1      
[31] magrittr_2.0.3    ps_1.7.5          digest_0.6.33     processx_3.8.2    rstudioapi_0.15.0 xtable_1.8-4     
[37] lifecycle_1.0.3   R.methodsS3_1.8.2 R.oo_1.25.0       vctrs_0.6.4       evaluate_0.22     glue_1.6.2       
[43] styler_1.10.2     fansi_1.0.5       rmarkdown_2.25    purrr_1.0.2       tools_4.3.1       pkgconfig_2.0.3  
[49] ellipsis_0.3.2    htmltools_0.5.6.1

When installing directly on the terminal:

~$ sudo Rscript -e "devtools::install_github('r-transit/tidytransit',  type = 'source')"
Using github PAT from envvar GITHUB_TOKEN
Downloading GitHub repo r-transit/tidytransit@HEAD

── R CMD build ───────────────────────────────────────────────────────────────────────────────────
   checking for file ‘/tmp/RtmpSID7ow/remotes5487467a6aea/r-transit-tidytransit-878e64a/DESCRIPTIO✔  checking for file ‘/tmp/RtmpSID7ow/remotes5487467a6aea/r-transit-tidytransit-878e64a/DESCRIPTION’
─  preparing ‘tidytransit’:
✔  checking DESCRIPTION meta-information ...
─  checking for LF line-endings in source and make files and shell scripts
─  checking for empty or unneeded directories
   Removed empty directory ‘tidytransit/data-raw’
─  building ‘tidytransit_1.6.0.tar.gz’

Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
* installing *source* package ‘tidytransit’ ...
** using staged installation
** R
** data
*** moving datasets to lazyload DB
** inst
** byte-compile and prepare package for lazy loading

 *** caught segfault ***
address 0x55cd63225d58, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...
Segmentation fault (core dumped)
ERROR: lazy loading failed for package ‘tidytransit’
* removing ‘/usr/local/lib/R/site-library/tidytransit’
Warning message:
In i.p(...) :
  installation of package ‘/tmp/RtmpSID7ow/file54873ff2a5f0/tidytransit_1.6.0.tar.gz’ had non-zero exit status

The documentation on this kind of error ("caught segfault ") is very limited in google.

I also removed completely my R installation and deleted pkgs folders, and re-installed again, making tidytransit one of my priorities to install, and the error still occurs!

It is odd, because it is the only package with this error, among 505 fresh installs...

Any clue? Thanks!

polettif commented 1 year ago

That's very odd indeed. I cannot reproduce the issue with R 4.2.3 or a fresh install of R 4.3.1. "Caught segfault" also looks like some C++ level code which tidytransit does not use. My first thought was an issue with the recently updated gtfsio (sorry @dhersz) but that also works perfectly fine.

The following packages are in your sessionInfo and not in my clean reinstall, perhaps we can find a hint there:

   package     version
   <chr>       <chr>  
 1 jsonlite    1.8.7  
 2 miniUI      0.1.1.1
 3 promises    1.2.1  
 4 reprex      2.0.2  
 5 clipr       0.8.0  
 6 jquerylib   0.1.4  
 7 callr       3.7.3  
 8 later       1.3.1  
 9 yaml        2.3.7  
10 fastmap     1.1.1  
11 mime        0.12   
12 knitr       1.44   
13 R.cache     0.16.0 
14 bslib       0.5.1  
15 R.utils     2.12.2 
16 cachem      1.0.8  
17 httpuv      1.6.12 
18 xfun        0.40   
19 sass        0.4.7  
20 fs          1.6.3  
21 memoise     2.0.1  
22 withr       2.5.1  
23 ps          1.7.5  
24 processx    3.8.2  
25 rstudioapi  0.15.0 
26 xtable      1.8-4  
27 R.methodsS3 1.8.2  
28 R.oo        1.25.0 
29 evaluate    0.22   
30 styler      1.10.2 
31 rmarkdown   2.25   
32 purrr       1.0.2  
33 ellipsis    0.3.2  
34 htmltools   0.5.6.1

Otherwise I'm out of ideas at the moment, and irrecoverable exception occurred. R is aborting now doesn't look like something I know a enough about to help.

dhersz commented 1 year ago

There seems to be a problem when compiling the package from source.

Since you're using Ubuntu 22 and R 4.3, you can try using a r-universe built binary:

install.packages('tidytransit', repos = c('https://r-transit.r-universe.dev/bin/linux/jammy/4.3/'))
dhersz commented 1 year ago

This SO answer (https://stackoverflow.com/a/50163562/13202041) also offers a clue of what might be going on. I'd try installing any tidytransit's upstream dependency from source and pay a close attention to the log messages, to see if there is a hint there.

Something that comes up to mind is that sf relies on some system packages that need to be manually installed in Linux. Perhaps these system dependencies may need to be updated to correctly install sf, which in turn make them a tidytransit dependency as well (I remember I had some free(): invalid pointer and segmentation fault errors before when trying to use sf with incorrect system dependencies - and just to be clear, the package would install without any issues, but the errors would be raised when trying to use some functions).

sf Ubuntu installation instructions: https://github.com/r-spatial/sf#ubuntu

temospena commented 1 year ago

Thank you.

There are other people reporting this error related with gis stuff, but no solutions provided.

https://community.rstudio.com/t/caught-segfault-again/161735

Apparently @robinlovelace is having the same error from today, but with other stuff. So, maybe not a tidytransit problem, but any gis R pkg update that is messing with others?

temospena commented 1 year ago

There seems to be a problem when compiling the package from source.

Since you're using Ubuntu 22 and R 4.3, you can try using a r-universe built binary:

install.packages('tidytransit', repos = c('https://r-transit.r-universe.dev/bin/linux/jammy/4.3/'))

this solved for the instalation problem, thank you!!!

~$ sudo Rscript -e "install.packages('tidytransit', repos = c('https://r-transit.r-universe.dev/bin/linux/jammy/4.3/'))"
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
trying URL 'https://r-transit.r-universe.dev/bin/linux/jammy/4.3/src/contrib/tidytransit_1.6.0.tar.gz'
Content type 'application/x-gzip' length 4921434 bytes (4.7 MB)
==================================================
downloaded 4.7 MB

* installing *binary* package ‘tidytransit’ ...
* DONE (tidytransit)

The downloaded source packages are in
        ‘/tmp/RtmpfoENp5/downloaded_packages’
polettif commented 1 year ago

Thanks @dhersz!