Warning message for V8 package - "This system has a very old version of libv8"?

Hello,
I am trying to use the rmapshaper package and having an issue which I think might possibly be related to the warning message I get from library(V8) : “Warning: this system has a very old version of libv8. Some packages may not work”.

I keep getting the error “SyntaxError: Unexpected token function” when using the ms_simplify() function. I get this error even when I just copy and paste the exact example given in the documentation: (ms_simplify function - RDocumentation)

ms_simplify(poly_sf, keep=0.5)
Error: SyntaxError: Unexpected token function

When I load rmapshaper I also get the following warning message:
library(rmapshaper)
Warning: v8 Engine is version 3.14.5.9 but version >=6 is required for full functionality. Some rmapshaper functions, notably ms_clip() and ms_erase(), may not work. See GitHub - jeroen/V8: Embedded JavaScript Engine for R for help installing a modern version of v8 on your operating system.

I did go to the link, but I didn’t understand how to install a newer version of the v8 engine , only the package… Sorry I really don’t understand anything about V8. I did make sure I had the most up to date version of the V8 package, but that didn’t change any warning or error messages.

If anyone has any ideas, I’d be very grateful!

Thanks,
Jess

I get something similar using rmapshaper::ms_simplify():

Error: SyntaxError: Unexpected token .

Could it have something to do with the retirement of rgdal, rgeos and maptools. It seems rmapshaper depends on some of these.

About the retirement:
https://r-spatial.org/r/2022/04/12/evolution.html

Latest status update: sp evolution status: examples of migration from retiring packages

Hi, rmapshaper maintainer here. This doesn’t have anything to do with the retirement of rgdal and friends, rather the version of the v8 system library (C++) that the V8 R package is built with. Usually just reinstalling the V8 R package should be enough, as Jeroen has done a lot of work lately to ensure that installations are built with a new enough version of v8. If you are on Windows or Mac and installing the binary version of the V8 R package (install.packages("V8", type = "binary")), it will be be built with an up-to-date version of v8 and you should be fine. If you are on Linux or need to install from source on MacOS, you should set the DOWNLOAD_STATIC_LIBV8 environment variable before installing it:

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

There may reasons be why that is not possible on your system, in which case the V8 R package will be built with whatever version of the v8 library is available on your system. The V8 installation instructions should help give you guidance on updating the v8 library on many operating systems.

1 Like

Thanks very much Andy for that info, that’s super helpful.