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

ms_innerlines has error in 0.5.0 #157

Closed
al-obrien opened this issue May 15, 2023 · 23 comments
Closed

ms_innerlines has error in 0.5.0 #157

al-obrien opened this issue May 15, 2023 · 23 comments

Comments

@al-obrien
Copy link

The latest version, 0.5.0, now produces an error when using ms_innerlines(). This does not occur if rolling back to 0.4.6.

The error is:

Error in context_eval(join(src), private$context, serialize, await) : 
  SyntaxError: Unexpected token .

I reproduced this in the following:

file <- system.file("gpkg/nc.gpkg", package = "sf")
nc_sf <- sf::read_sf(file)
rmapshaper::ms_innerlines(nc_sf)

Session Info

> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: RHEL

Matrix products: default
BLAS/LAPACK: /usr/lib64/libopenblasp-r0.3.3.so

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

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

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.10        pillar_1.7.0       compiler_3.6.3     class_7.3-15       tools_3.6.3        jsonlite_1.8.0     lifecycle_1.0.1   
 [8] tibble_3.1.6       lattice_0.20-38    pkgconfig_2.0.3    rlang_1.0.6        DBI_1.1.2          cli_3.2.0          rstudioapi_0.13   
[15] curl_4.3.2         e1071_1.7-11       dplyr_1.0.8        generics_0.1.2     vctrs_0.4.1        classInt_0.4-7     grid_3.6.3        
[22] tidyselect_1.1.2   glue_1.6.2         geojsonsf_2.0.3    sf_1.0-8           R6_2.5.1           fansi_1.0.3        sp_1.5-0          
[29] purrr_0.3.4        magrittr_2.0.3     rmapshaper_0.5.0   ellipsis_0.3.2     units_0.8-0        assertthat_0.2.1   renv_0.15.5       
[36] V8_4.2.0           KernSmooth_2.23-16 utf8_1.2.2         proxy_0.4-27       crayon_1.5.1   
@ateucher
Copy link
Owner

This is on Linux (RHEL), #159 is on Windows. @pachadotdev, can you tell me what platform you are using in #158?

@ateucher
Copy link
Owner

Can you please report the output of: V8::engine_info()

@al-obrien
Copy link
Author

Here you go:

> V8::engine_info()
$version
[1] "6.8.275.32"

$numeric_version
[1] ‘6.8.275.32

@ateucher
Copy link
Owner

ateucher commented May 16, 2023

Ok, that's pretty old, but as far as I remember v8 >= 6 should work, but it's possible the new version of the mapshaper library has code that requires a newer version of V8.

Can you try reinstalling V8 with:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")

@ateucher
Copy link
Owner

@lewkrr and @pachadotdev, can you also please paste the output of V8::engine_info()?

@al-obrien
Copy link
Author

Ok, that's pretty old, but as far as I remember v8 >= 6 should work, but it's possible the new version of the mapshaper library has code that requires a newer version of V8.

Can you try reinstalling V8 with:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")

I followed those instructions and the same version is stated under engine_info(), "6.8.275.32" for V8 4.3.0

@pachadotdev
Copy link

pachadotdev commented May 16, 2023

This is on Linux (RHEL), #159 is on Windows. @pachadotdev, can you tell me what platform you are using in #158?

hi @ateucher, I am on Ubuntu 22 and my info is

> V8::engine_info()
$version
[1] "7.8.279.23-node.56"

$numeric_version
[1] ‘7.8.279.23’

@ateucher
Copy link
Owner

So I think this is because the new mapshaper uses the ?. optional chaining operator, which is only supported in V8 >= 8.1.307.30.

I'm going to have to figure out if we can update the version of the static libv8 on different platforms...

@lewkrr
Copy link

lewkrr commented May 23, 2023

@lewkrr and @pachadotdev, can you also please paste the output of V8::engine_info()?

> V8::engine_info()

$version
[1] "6.2.414.50"

$numeric_version
[1] ‘6.2.414.50’

I should say that I uninstalled the latest rmapshaper and installed an older version from the archive so that I could get this function to work.

How does one update the V8 version on their machine? Is there a way to do this from within R?

Thanks so much for taking this up, ateucher!

@ateucher
Copy link
Owner

Interesting, from what I can see in the V8 repo, Windows should have libv8 9.1.

@lewkrr can you try reinstalling V8, and be sure to get the binary (install.packages("V8", type = "binary")).

Then run V8::engine_info() again?

@ateucher
Copy link
Owner

ateucher commented May 23, 2023

@pachadotdev I think you might be able to do something like this:

$ sudo apt-get install libnode-dev

Then in R:

Sys.setenv(DISABLE_STATIC_LIBV8 = 1)
Sys.unsetenv("DOWNLOAD_STATIC_LIBV8")
install.packages("V8", type = "source")

(related: jeroen/V8#140)

@ateucher
Copy link
Owner

ateucher commented May 23, 2023

@al-obrien might this issue help you at all? jeroen/V8#168

@pachadotdev
Copy link

@ateucher hi! the problem persists, I shall stick to 0.4.6

@ateucher
Copy link
Owner

@ateucher hi! the problem persists, I shall stick to 0.4.6

Sure, that's a fine choice. You should be able to build V8 with a modern libv8 but I'm afraid that's outside of my domain. The other option is to install the node mapshaper library (npm install -g mapshaper), and call all of the mapshaper commands with sys = TRUE).

@al-obrien
Copy link
Author

al-obrien commented May 24, 2023

@al-obrien might this issue help you at all? jeroen/V8#168

This may take me some time to confirm as I do not have permissions to install Linux software on the system. For now I will also roll-back the version and try to follow-up if IT approves the change. If there are any other options I am all ears too

@ateucher
Copy link
Owner

@pachadotdev can you please post the output of: dpkg -l | grep -E "lib(node|v8)".

@al-obrien the v8 engine you have seems to suggest that your system has an old gcc version (4.x), according to the logic here.

@pachadotdev
Copy link

dpkg -l | grep -E "lib(node|v8)"

~ $ dpkg -l | grep -E "lib(node|v8)"
ii  libnode-dev                                12.22.9~dfsg-1ubuntu3                      amd64        evented I/O for V8 javascript (development files)
ii  libnode72:amd64                            12.22.9~dfsg-1ubuntu3                      amd64        evented I/O for V8 javascript - runtime library

@ateucher
Copy link
Owner

Interesting, thanks. So you have a very new libv8 (libnode) on your system, but can't get the V8 R package to build with it. Might be worth following up at the V8 repo.

@clozanoruiz
Copy link

Hi,
just to add I´m also facing this error. R-3.6.3 on Windows (RTools35). Looking at the V8_4.8.3 source package I see a file named configure.win (which in turns references a legay.win file) that seems to suggest that R-3.6 users are stuck with V8 6.2.414.50.
So I guess I will have to revert to rmapshaper 0.4.6 and stay there till we upgrade to R 4.x

@ateucher
Copy link
Owner

Thanks for reporting @clozanoruiz - I'm afraid you're right. I can't do much about this in rmapshaper, so I'm going to have to just add a startup message informing users about the libv8 version requirements.

@michal-kinel
Copy link

Hi i had similar issue with rmapshaper::ms_simplify

library(sf)
test_coord <- st_sfc(st_point(c(-3.7035285, 40.4169473)), crs = 4326)
test_buffer <- st_buffer(st_transform(test_coord, crs = 32630), dist = 300)
rmapshaper::ms_simplify(test_buffer, keep = 0.35, keep_shapes = T)

I got the same error message:

The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
which was just loaded, will retire in October 2023.
Please refer to R-spatial evolution reports for details, especially
https://r-spatial.org/r/2023/05/15/evolution4.html.
It may be desirable to make the sf package available;
package maintainers should consider adding sf to Suggests:.
The sp package is now running under evolution status 2
(status 2 uses the sf package in place of rgdal)
Error: SyntaxError: Unexpected token '.'

V8 issue:

dpkg -l | grep -E "lib(node|v8)"
ii  libnode-dev                                12.22.9~dfsg-1ubuntu3                   amd64        evented I/O for V8 javascript (development files)
ii  libnode72:amd64                            12.22.9~dfsg-1ubuntu3                   amd64        evented I/O for V8 javascript - runtime library

in R:

> V8::engine_info()
$version
[1] "7.8.279.23-node.56"

$numeric_version
[1] ‘7.8.279.23’

The problem was that I use the r_profile so I accessed usethis::edit_r_profile() and disabled loading of anything. I then restarted the session and:

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")

After that:

> V8::engine_info()
$version
[1] "9.6.180.12"

$numeric_version
[1] ‘9.6.180.12’

This solved the problem with the sample code.

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

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3 
LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3;  LAPACK version 3.10.0

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

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

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

other attached packages:
[1] sf_1.0-13

loaded via a namespace (and not attached):
 [1] vctrs_0.6.3           cli_3.6.1             rlang_1.1.1          
 [4] DBI_1.1.3             KernSmooth_2.23-21    generics_0.1.3       
 [7] jsonlite_1.8.7        glue_1.6.2            V8_4.3.2             
[10] e1071_1.7-13          sp_2.0-0              fansi_1.0.4          
[13] grid_4.3.1            classInt_0.4-9        tibble_3.2.1         
[16] rmapshaper_0.5.0.9000 lifecycle_1.0.3       compiler_4.3.1       
[19] dplyr_1.1.2           timechange_0.2.0      Rcpp_1.0.10          
[22] pkgconfig_2.0.3       rstudioapi_0.14       lattice_0.21-8       
[25] R6_2.5.1              class_7.3-22          tidyselect_1.2.0     
[28] utf8_1.2.3            pillar_1.9.0          curl_5.0.1           
[31] magrittr_2.0.3        tools_4.3.1           proxy_0.4-27         
[34] lubridate_1.9.2       geojsonsf_2.0.3       units_0.8-2          

@rikudoukarthik
Copy link

Sys.setenv(DOWNLOAD_STATIC_LIBV8 = 1)
install.packages("V8")

I was facing the same issue with ms_simplify(). @michal-kinel's solution worked for me (updated local V8 version).

@ateucher
Copy link
Owner

ateucher commented Jan 8, 2024

I'm marking this now closed via cb8ca34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants