Giter Club home page Giter Club logo

v8's Introduction

V8

Embedded JavaScript and WebAssembly Engine for R

CRAN_Status_Badge CRAN RStudio mirror downloads

An R interface to V8: Google's open source JavaScript and WebAssembly engine. This package can be compiled either with V8 version 6 and up or NodeJS when built as a shared library.

Getting started

About the R package:

To see some quick examples in R run:

library(V8)
example(v8)

Installation

Binary packages for OS-X or Windows can be installed directly from CRAN:

install.packages("V8")

On Linux you need a suitable libv8 installation, see below.

Linux: Static libv8

On amd64/arm64 Linux/MacOS platforms it is possible (and recommended) to automatically download a suitable static build of libv8 during package installation. This is enabled by default on Ubuntu, RHEL, and MacOS. For other systems you can opt-in by setting an environment variable DOWNLOAD_STATIC_LIBV8 during installation, for example:

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

This way, you can install the R package on any x64 Linux system, without external system requirements. Alternatively, it is also still possible to install libv8 from your distribution as described below. This may be needed for servers running other architectures, or when building the R package without internet access.

Debian / Ubuntu

Installation from source on Linux requires libv8. On Ubuntu / Debian you need to install either libv8-dev, or libnode-dev. On the latest systems, libv8-dev is actually an alias for libnode-dev so they are the same:

# Debian and Ubuntu
sudo apt-get install -y libv8-dev

Fedora / Redhat

On Fedora we need v8-devel (which Fedora provides as part of nodejs):

sudo yum install v8-devel

On CentOS 7 / RHEL 7 we install first need to enable EPEL:

sudo yum install epel-release
sudo yum install v8-devel

On RockyLinux 8 / RHEL 8, v8-devel can be installed from the nodejs:16-epel module repository:

yum --refresh --enablerepo=epel-testing-modular install @nodejs:16-epel/minimal v8-devel

Arch Linux

Arch users are advised to install the v8-r package, which has been configured to work well with R. Installation can done through your preferred AUR helper such as yay, Trizen, etc. However, since V8 contains a large codebase and (re-)compilation takes a while, users may prefer to build and update it manually. For example,

## Arch
cd /tmp
yay -G v8-r   
cd v8-r
makepkg -si

Homebrew

On OS-X use v8 from Homebrew:

brew install v8

But it is much easier to set DOWNLOAD_STATIC_LIBV8 instead.

Hello World

# Create a new context
library(V8)
ctx <- v8()

# Evaluate some code
ctx$eval("var foo = 123")
ctx$eval("var bar = 456")
ctx$eval("foo+bar")

# Assign / get objects
ctx$assign("foo", JS("function(x){return x*x}"))
ctx$assign("bar", JS("foo(9)"))
ctx$get("bar")

Call functions from JavaScript libraries

ctx <- V8::v8()
ctx$source("https://cdnjs.cloudflare.com/ajax/libs/coffee-script/1.4.0/coffee-script.min.js")
jscode <- ctx$call("CoffeeScript.compile", "square = (x) -> x * x", list(bare = TRUE))
ctx$eval(jscode)
ctx$call("square", 9)

v8's People

Contributors

edwindj avatar grantmcdermott avatar janmarvin avatar jeroen avatar jimhester avatar kapouer avatar kenahoo avatar mnazarov avatar noamross avatar qulogic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

v8's Issues

Cryptic error/warning message on install [Ubuntu 16.04]

While updating a bunch of packages it turned out that V8 needs to be installed as a new dependency. I installed libv8-dev as suggested (i.e., libv8-dev (3.14.5.8-5ubuntu2) as provided by Ubuntu 16.04), and the repeated install seems to be successful, but I noticed the following message:

<snip>
Package libv8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libv8.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libv8' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lv8
** libs <snip>

I find this message somewhat cryptic and although the package seems to have been built OK, I am not sure if some problems remain... For example, libv8.pc is not found in any of the packages provided by Ubuntu; similarly, there is no package named libv8 in the repository.

Incomplete expressions

Find out of there is a way to determine if a string is an incomplete piece of JavaScript so that we can prompt for additional input in the interactive console.

Maybe the shell example has a hint.

Source - TypeError

Hi,

I'm unsure as to why I'm getting this error trying to source brain.js

library(V8)

ct <- v8()

ct$source("https://raw.githubusercontent.com/harthur-org/brain.js/master/browser.js")
Error in context_eval(join(src), private$context) : 
  TypeError: Object function Object() { [native code] } has no method 'assign'

Inconsistencies with NA and other types of 'missingness'

I noticed that different classes of NA were treated differently on a round trip:

library(V8)
ct <- v8()

## Logical and character of length one return as NULL
ct$assign("na", NA)
ct$get("na")
#> NULL

ct$assign("na_char", NA_character_)
ct$get("na_char")
#> NULL

## Real, integer, and complex return as "NA" string
ct$assign("na_real", NA_real_)
ct$get("na_real")
#> [1] "NA"

ct$assign("na_int", NA_integer_)
ct$get("na_int")
#> [1] "NA"

ct$assign("na_complex", NA_complex_)
ct$get("na_complex")
#> [1] "NA"

## When vector is greater than length 1, get vector of NAs back:
ct$assign("nas", c(NA, NA))
ct$get("nas")
#> [1] NA NA

I then looked at other 'missing' types: NaN and NULL:

## NaN returns as "NaN" string
ct$assign("nan", NaN)
ct$get("nan")
#> [1] "NaN"

## NULL returns as an empty list()
ct$assign("null_", NULL)
ct$get("null_")
#> named list()

I think the inconsistencies in the NA types is a bit of a problem, but not sure what you think about the NaN and NULL situations?

install_github fails with ANTICONF error Mac

Like #22 I'm getting an ANTICONF error on my mac:

Downloading GitHub repo jeroenooms/V8@master
from URL https://api.github.com/repos/jeroenooms/V8/zipball/master
Installing V8
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/zg/hy0k4g312536_4l1qc1w27640000gn/T/RtmpeKDiKq/devtools35d67789898/jeroenooms-V8-7163157'  \
  --library='/Library/Frameworks/R.framework/Versions/3.2/Resources/library' --install-tests 

* installing *source* package ‘V8’ ...
Package libv8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libv8.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libv8' found
Using PKG_CFLAGS=-I/usr/local/opt/v8-315/include
Using PKG_LIBS=-L/usr/local/opt/v8-315/lib -lv8
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libv8 was not found. Try installing:
 * deb: libv8-3.14-dev | libv8-dev (Debian, Ubuntu)
 * rpm: v8-devel (Fedora, EPEL)
 * brew: v8-315 (OSX) -- NOT regular v8! Tap from homebrew/versions
 * csw: libv8_dev (Solaris)
If libv8 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libv8.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/V8’
* restoring previous ‘/Library/Frameworks/R.framework/Versions/3.2/Resources/library/V8’

Additionally, /usr/local/opt/v8-315 has the required files in it, I have v8 installed (FYI in case this is the issue) and g++. Can I get some guidance to track this down?

Brandons-iMac:~ brandonhurr$ brew install v8-315
Warning: homebrew/versions/v8-315-3.15.11.18 already installed
Brandons-iMac:~ brandonhurr$ v8
V8 version 4.7.80.25 [sample shell]
> quit()
Brandons-iMac:v8-315 brandonhurr$ cd include
Brandons-iMac:include brandonhurr$ ls
v8-debug.h  v8-profiler.h   v8.h
v8-preparser.h  v8-testing.h    v8stdint.h
Brandons-iMac:include brandonhurr$ g++
clang: error: no input files
Session info ---------------------------------------------------------------------------------------------------------------------------------------------
 setting  value                       
 version  R version 3.2.4 (2016-03-10)
 system   x86_64, darwin13.4.0        
 ui       AQUA                        
 language (EN)                        
 collate  en_US.UTF-8                 
 tz       America/Los_Angeles         
 date     2016-03-15                  

Packages -------------------------------------------------------------------------------------------------------------------------------------------------
 package  * version     date       source                          
 curl       0.9.6       2016-02-17 CRAN (R 3.2.3)                  
 devtools   1.10.0.9000 2016-02-26 Github (hadley/devtools@b6a23be)
 digest     0.6.9       2016-01-08 CRAN (R 3.2.3)                  
 git2r      0.13.1      2015-12-10 CRAN (R 3.2.3)                  
 httr       1.1.0       2016-01-28 CRAN (R 3.2.3)                  
 knitr      1.12.3      2016-01-22 CRAN (R 3.2.3)                  
 magrittr * 1.5         2014-11-22 CRAN (R 3.2.0)                  
 memoise    1.0.0       2016-01-29 CRAN (R 3.2.3)                  
 R6         2.1.2       2016-01-26 CRAN (R 3.2.3)                  
 withr      1.0.1       2016-02-04 CRAN (R 3.2.3) 

Issues with V8 on Arch Linux

Hi,

Thanks a lot for this package, I can't wait to test it out.
I do have a problem with the installation everytime I try.

Here is the output (sorry because it is long)

install.packages("V8")
trying URL 'http://cran.rstudio.com/src/contrib/V8_0.5.tar.gz'
Content type 'application/x-gzip' length 108659 bytes (106 KB)
opened URL
==================================================
downloaded 106 KB

* installing *source* packageV8...
** packageV8successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/local/lib/R/include     -I/usr/local/include -I"/usr/local/lib/R/library/Rcpp/include"   -fpic  -O3    -c RcppExports.cpp -o RcppExports.o
g++ -I/usr/local/lib/R/include     -I/usr/local/include -I"/usr/local/lib/R/library/Rcpp/include"   -fpic  -O3    -c V8.cpp -o V8.o
V8.cpp: In functionvoid ctx_finalizer(v8::Persistent<v8::Context>*)’:
V8.cpp:32:14: error:class v8::Persistent<v8::Context>has no member namedDisposecontext->Dispose();
              ^
V8.cpp: In functionv8::Handle<v8::Script> compile_source(std::string)’:
V8.cpp:40:27: error:Newis not a member ofv8::StringHandle<String> source = String::New(src.c_str());
                           ^
V8.cpp: At global scope:
V8.cpp:46:39: error:Argumentsdoes not name a type
 static Handle<Value> ConsoleLog(const Arguments& args) {
                                       ^
V8.cpp: In functionv8::Handle<v8::Value> ConsoleLog(const int&)’:
V8.cpp:47:26: error: request for memberLengthinargs’, which is of non-class typeconst intfor (int i=0; i < args.Length(); i++) {
                          ^
V8.cpp:48:5: error:AsciiValueis not a member ofv8::StringString::AsciiValue str(args[i]->ToString());
     ^
V8.cpp:49:20: error:strwas not declared in this scope
     Rprintf("%s", *str);
                    ^
V8.cpp:52:24: error: too few arguments to functionv8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
   return v8::Undefined();
                        ^
In file included from V8.cpp:16:0:
/usr/include/v8.h:312:28: note: declared here
   friend Handle<Primitive> Undefined(Isolate* isolate);
                            ^
V8.cpp: At global scope:
V8.cpp:56:40: error:Argumentsdoes not name a type
 static Handle<Value> ConsoleWarn(const Arguments& args) {
                                        ^
V8.cpp: In functionv8::Handle<v8::Value> ConsoleWarn(const int&)’:
V8.cpp:57:26: error: request for memberLengthinargs’, which is of non-class typeconst intfor (int i=0; i < args.Length(); i++) {
                          ^
V8.cpp:58:5: error:AsciiValueis not a member ofv8::StringString::AsciiValue str(args[i]->ToString());
     ^
V8.cpp:59:43: error:strwas not declared in this scope
     Rf_warningcall_immediate(R_NilValue, *str);
                                           ^
V8.cpp:61:24: error: too few arguments to functionv8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
   return v8::Undefined();
                        ^
In file included from V8.cpp:16:0:
/usr/include/v8.h:312:28: note: declared here
   friend Handle<Primitive> Undefined(Isolate* isolate);
                            ^
V8.cpp: At global scope:
V8.cpp:65:41: error:Argumentsdoes not name a type
 static Handle<Value> ConsoleError(const Arguments& args) {
                                         ^
V8.cpp: In functionv8::Handle<v8::Value> ConsoleError(const int&)’:
V8.cpp:66:11: error: request for memberLengthinargs’, which is of non-class typeconst intif(args.Length()){
           ^
V8.cpp:67:12: error:ThrowExceptionis not a member ofv8return v8::ThrowException(args[0]);
            ^
V8.cpp:67:37: error: invalid typesconst int[int]’ for array subscript
     return v8::ThrowException(args[0]);
                                     ^
V8.cpp:69:24: error: too few arguments to functionv8::Handle<v8::Primitive> v8::Undefined(v8::Isolate*)’
   return v8::Undefined();
                        ^
In file included from V8.cpp:16:0:
/usr/include/v8.h:312:28: note: declared here
   friend Handle<Primitive> Undefined(Isolate* isolate);
                            ^
/usr/include/v8.h: In functionctxptr make_context(bool)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:75:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:79:17: error:NewSymbolis not a member ofv8::Stringglobal->Set(String::NewSymbol("console"), console);
                 ^
V8.cpp:80:18: error:NewSymbolis not a member ofv8::Stringconsole->Set(String::NewSymbol("log"), FunctionTemplate::New(ConsoleLog));
                  ^
V8.cpp:80:76: error: no matching function for call tov8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
     console->Set(String::NewSymbol("log"), FunctionTemplate::New(ConsoleLog));
                                                                            ^
V8.cpp:80:76: note: candidate is:
In file included from V8.cpp:16:0:
/usr/include/v8.h:3696:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
   static Local<FunctionTemplate> New(
                                  ^
/usr/include/v8.h:3696:34: note:   no known conversion for argument 1 fromv8::Handle<v8::Value>(const int&)’ tov8::Isolate*V8.cpp:81:18: error:NewSymbolis not a member ofv8::Stringconsole->Set(String::NewSymbol("warn"), FunctionTemplate::New(ConsoleWarn))
                  ^
V8.cpp:81:78: error: no matching function for call tov8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
    console->Set(String::NewSymbol("warn"), FunctionTemplate::New(ConsoleWarn));
                                                                             ^
V8.cpp:81:78: note: candidate is:
In file included from V8.cpp:16:0:
/usr/include/v8.h:3696:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
   static Local<FunctionTemplate> New(
                                  ^
/usr/include/v8.h:3696:34: note:   no known conversion for argument 1 fromv8::Handle<v8::Value>(const int&)’ tov8::Isolate*V8.cpp:82:18: error:NewSymbolis not a member ofv8::Stringconsole->Set(String::NewSymbol("error"), FunctionTemplate::New(ConsoleError
                  ^
V8.cpp:82:80: error: no matching function for call tov8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
  console->Set(String::NewSymbol("error"), FunctionTemplate::New(ConsoleError));
                                                                             ^
V8.cpp:82:80: note: candidate is:
In file included from V8.cpp:16:0:
/usr/include/v8.h:3696:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
   static Local<FunctionTemplate> New(
                                  ^
/usr/include/v8.h:3696:34: note:   no known conversion for argument 1 fromv8::Handle<v8::Value>(const int&)’ tov8::Isolate*V8.cpp:85:17: error:NewSymbolis not a member ofv8::Stringglobal->Set(String::NewSymbol("print"), FunctionTemplate::New(ConsoleLog));
                 ^
V8.cpp:85:77: error: no matching function for call tov8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
     global->Set(String::NewSymbol("print"), FunctionTemplate::New(ConsoleLog));
                                                                             ^
V8.cpp:85:77: note: candidate is:
In file included from V8.cpp:16:0:
/usr/include/v8.h:3696:34: note: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Handle<v8::Value>, v8::Handle<v8::Signature>, int)
   static Local<FunctionTemplate> New(
                                  ^
/usr/include/v8.h:3696:34: note:   no known conversion for argument 1 fromv8::Handle<v8::Value>(const int&)’ tov8::Isolate*V8.cpp:88:46: error: no matching function for call tov8::Context::New(NULL, v8::Handle<v8::ObjectTemplate>&)’
   lstail->context = Context::New(NULL, global);
                                              ^
V8.cpp:88:46: note: candidate is:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5751:25: note: static v8::Local<v8::Context> v8::Context::New(v8::Isolate*, v8::ExtensionConfiguration*, v8::Handle<v8::ObjectTemplate>, v8::Handle<v8::Value>)
   static Local<Context> New(
                         ^
/usr/include/v8.h:5751:25: note:   no known conversion for argument 2 fromv8::Handle<v8::ObjectTemplate>tov8::ExtensionConfiguration*/usr/include/v8.h: In functionbool context_enable_typed_arrays(Rcpp::XPtr<v8::Persistent<v8::Context> >)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:97:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:98:36: error: no matching function for call tov8::Context::Scope::Scope(v8::Persistent<v8::Context>&)’
   Context::Scope context_scope(*ctx);
                                    ^
V8.cpp:98:36: note: candidates are:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handle<v8::Context>)
     explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                        ^
/usr/include/v8.h:5849:24: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>tov8::Handle<v8::Context>/usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
   class Scope {
         ^
/usr/include/v8.h:5847:9: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>toconst v8::Context::Scope&V8.cpp:99:40: error: base operand of->has non-pointer typev8::Persistent<v8::Context>v8_typed_array::AttachBindings((*ctx)->Global());
                                        ^
In file included from V8.cpp:16:0:
/usr/include/v8.h: In functionstd::string context_eval(std::string, Rcpp::XPtr<v8::Persistent<v8::Context> >)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:115:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:116:36: error: no matching function for call tov8::Context::Scope::Scope(v8::Persistent<v8::Context>&)’
   Context::Scope context_scope(*ctx);
                                    ^
V8.cpp:116:36: note: candidates are:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handle<v8::Context>)
     explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                        ^
/usr/include/v8.h:5849:24: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>tov8::Handle<v8::Context>/usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
   class Scope {
         ^
/usr/include/v8.h:5847:9: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>toconst v8::Context::Scope&V8.cpp:123:5: error:AsciiValueis not a member ofv8::StringString::AsciiValue exception_str(exception);
     ^
V8.cpp:124:34: error:exception_strwas not declared in this scope
     throw std::invalid_argument(*exception_str);
                                  ^
V8.cpp:131:5: error:AsciiValueis not a member ofv8::StringString::AsciiValue exception_str(exception);
     ^
V8.cpp:132:31: error:exception_strwas not declared in this scope
     throw std::runtime_error(*exception_str);
                               ^
In file included from V8.cpp:16:0:
/usr/include/v8.h: In functionbool context_validate(std::string, Rcpp::XPtr<v8::Persistent<v8::Context> >)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:148:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:149:36: error: no matching function for call tov8::Context::Scope::Scope(v8::Persistent<v8::Context>&)’
   Context::Scope context_scope(*ctx);
                                    ^
V8.cpp:149:36: note: candidates are:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handle<v8::Context>)
     explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                        ^
/usr/include/v8.h:5849:24: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>tov8::Handle<v8::Context>/usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
   class Scope {
         ^
/usr/include/v8.h:5847:9: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>toconst v8::Context::Scope&/usr/include/v8.h: In functionbool context_assign_bin(std::string, Rcpp::RawVector, Rcpp::XPtr<v8::Persistent<v8::Context> >)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:197:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:198:36: error: no matching function for call tov8::Context::Scope::Scope(v8::Persistent<v8::Context>&)’
   Context::Scope context_scope(*ctx);
                                    ^
V8.cpp:198:36: note: candidates are:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handle<v8::Context>)
     explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                        ^
/usr/include/v8.h:5849:24: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>tov8::Handle<v8::Context>/usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
   class Scope {
         ^
/usr/include/v8.h:5847:9: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>toconst v8::Context::Scope&V8.cpp:199:41: error: base operand of->has non-pointer typev8::Persistent<v8::Context>v8::Handle<v8::Object> global = (*ctx)->Global();
                                         ^
V8.cpp:202:32: error:Newis not a member ofv8::StringLocal<v8::String> mystring = v8::String::New((const char*) RAW(data), data.le
                                ^
V8.cpp:203:15: error:NewSymbolis not a member ofv8::Stringglobal->Set(String::NewSymbol(name.c_str()), mystring);
               ^
In file included from V8.cpp:16:0:
/usr/include/v8.h: In functionRcpp::RawVector context_get_bin(std::string, Rcpp::XPtr<v8::Persistent<v8::Context> >)’:
/usr/include/v8.h:832:13: error:v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
V8.cpp:214:15: error: within this context
   HandleScope handle_scope;
               ^
V8.cpp:215:36: error: no matching function for call tov8::Context::Scope::Scope(v8::Persistent<v8::Context>&)’
   Context::Scope context_scope(*ctx);
                                    ^
V8.cpp:215:36: note: candidates are:
In file included from V8.cpp:16:0:
/usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handle<v8::Context>)
     explicit V8_INLINE Scope(Handle<Context> context) : context_(context) {
                        ^
/usr/include/v8.h:5849:24: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>tov8::Handle<v8::Context>/usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
   class Scope {
         ^
/usr/include/v8.h:5847:9: note:   no known conversion for argument 1 fromv8::Persistent<v8::Context>toconst v8::Context::Scope&V8.cpp:216:41: error: base operand of->has non-pointer typev8::Persistent<v8::Context>v8::Handle<v8::Object> global = (*ctx)->Global();
                                         ^
V8.cpp:219:44: error:NewSymbolis not a member ofv8::StringLocal<v8::String> mystring = global->Get(String::NewSymbol(name.c_str()))->To
                                            ^
V8.cpp:221:13: error:class v8::Stringhas no member namedWriteAsciimystring->WriteAscii((char*) res.begin());
             ^
In file included from V8.cpp:16:0:
/usr/include/v8.h: In instantiation ofstatic void v8::NonCopyablePersistentTraits<T>::Uncompilable() [with O = v8::Object; T = v8::Context]’:
/usr/include/v8.h:611:17:   required fromstatic void v8::NonCopyablePersistentTraits<T>::Copy(const v8::Persistent<S, M>&, v8::NonCopyablePersistentTraits<T>::NonCopyablePersistent*) [with S = v8::Context; M = v8::NonCopyablePersistentTraits<v8::Context>; T = v8::Context; v8::NonCopyablePersistentTraits<T>::NonCopyablePersistent = v8::Persistent<v8::Context>]’
/usr/include/v8.h:6314:21:   required fromvoid v8::Persistent<T, M>::Copy(const v8::Persistent<S, M>&) [with S = v8::Context; M2 = v8::NonCopyablePersistentTraits<v8::Context>; T = v8::Context; M = v8::NonCopyablePersistentTraits<v8::Context>]’
/usr/include/v8.h:676:14:   required fromv8::Persistent<T, M>::Persistent(const v8::Persistent<T, M>&) [with T = v8::Context; M = v8::NonCopyablePersistentTraits<v8::Context>]’
V8.cpp:22:8:   required from here
/usr/include/v8.h:615:5: error: cannot convertv8::Primitive*tov8::Object* volatilein assignment
     TYPE_CHECK(O, Primitive);
     ^
/usr/local/lib/R/etc/Makeconf:142: recipe for target 'V8.o' failed
make: *** [V8.o] Error 1
ERROR: compilation failed for packageV8* removing/usr/local/lib/R/library/V8

I installed V8 from repos in Arch Linux (https://www.archlinux.org/packages/community/x86_64/v8/)

This is the version I actually use

V8 version 3.30.33.16 [console: readline]

and my session info

sessionInfo()
R version 3.1.3 RC (2015-03-08 r67957)
Platform: x86_64-unknown-linux-gnu (64-bit)
Running under: Arch Linux

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

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

other attached packages:
[1] jsonlite_0.9.14 curl_0.5        Rcpp_0.11.5 

Do you think the problem lie with my V8 installation. Do you have any recommandation ?

Thanks

With v8-7.4 I fail to build, because cannot find -lv8

After seeing #57, I wanted to move from v8-3.14 to v8-7.x. So I replaced the old one with 7.4.288.18-2 from https://aur.archlinux.org/packages/v8/. The issue is similar to #16, but this doesn't help to solve this issue here.

So I have currently installed:

Name            : v8
Version         : 7.4.288.18-2
Description     : Fast and modern Javascript engine used in Google Chrome.
Architecture    : x86_64

But I cannot build V8 for R:

* installing *source* package ‘V8’ ...
Using PKG_CFLAGS=-I/usr/include/v8 -I/usr/include/v8-3.14
Using PKG_LIBS=-lv8 -lv8_libplatform
** libs
rm -f V8.so RcppExports.o bindings.o
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -I"/home/abc/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -D_FORTIFY_SOURCE=2  -fvisibility=hidden -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c RcppExports.cpp -o RcppExports.o
g++ -std=gnu++11 -I"/usr/include/R/" -DNDEBUG -I/usr/include/v8 -I/usr/include/v8-3.14 -I"/home/abc/R/x86_64-pc-linux-gnu-library/3.5/Rcpp/include" -D_FORTIFY_SOURCE=2  -fvisibility=hidden -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -c bindings.cpp -o bindings.o
g++ -std=gnu++11 -shared -L/usr/lib64/R/lib -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -o V8.so RcppExports.o bindings.o -lv8 -lv8_libplatform -L/usr/lib64/R/lib -lR
/usr/bin/ld: cannot find -lv8
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R//make/shlib.mk:6: V8.so] Error 1
ERROR: compilation failed for package ‘V8’
* removing ‘/home/abc/R/x86_64-pc-linux-gnu-library/3.5/V8’
* restoring previous ‘/home/abc/R/x86_64-pc-linux-gnu-library/3.5/V8’
Installation failed: i.p(...) : (converted from warning) installation of package ‘/tmp/RtmpJLz048/file2e4818bed65c/V8_2.1.9000.tar.gz’ had non-zero exit status

The following packages were not able to be installed:
V8

increase memory limit?

I know node has the --max_old_space_size flag to increase the memory available. I don't know if this is possible in plain V8, particularly this version? But if so, it would be really helpful to be able to set a higher memory limit when you launch a new V8 context in R.

Installation fails on Debian

Trying to solve another issue (rich-iannone/DiagrammeR#333, solution suggested by @rich-iannone) I tried installing the DiagrammeRsvg package, which fails due to V8. I get:

> install.packages("DiagrammeRsvg")
Installing package into ‘/home/hseibold/R/x86_64-pc-linux-gnu-library/3.5’
(as ‘lib’ is unspecified)
also installing the dependency ‘V8’

trying URL 'https://cloud.r-project.org/src/contrib/V8_1.5.tar.gz'
Content type 'application/x-gzip' length 327013 bytes (319 KB)
==================================================
downloaded 319 KB

trying URL 'https://cloud.r-project.org/src/contrib/DiagrammeRsvg_0.1.tar.gz'
Content type 'application/x-gzip' length 826012 bytes (806 KB)
==================================================
downloaded 806 KB

* installing *source* package ‘V8’ ...
** package ‘V8’ successfully unpacked and MD5 sums checked
Using PKG_CFLAGS=-I/usr/include/v8-3.14
Using PKG_LIBS=-lv8
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because  was not found. Try installing:
 * deb: libv8-3.14-dev (formerly: libv8-dev) (Debian, Ubuntu)
 * rpm: v8-314-devel (formerly: v8-devel) (Fedora, EPEL)
 * brew: [email protected] (OSX) -- NOT regular v8! Tap from homebrew/versions
 * csw: libv8_dev (Solaris)
To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘V8’
* removing ‘/home/hseibold/R/x86_64-pc-linux-gnu-library/3.5/V8’
Warning in install.packages :
  installation of package ‘V8’ had non-zero exit status
ERROR: dependency ‘V8’ is not available for package ‘DiagrammeRsvg’
* removing ‘/home/hseibold/R/x86_64-pc-linux-gnu-library/3.5/DiagrammeRsvg’
Warning in install.packages :
  installation of package ‘DiagrammeRsvg’ had non-zero exit status

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

but unfortunately the library suggested does not exist

$ sudo apt-get install libv8-3.14-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package libv8-3.14-dev
E: Couldn't find any package by glob 'libv8-3.14-dev'
E: Couldn't find any package by regex 'libv8-3.14-dev'

I would appreciate some help in solving this.

My session info:

Session info ``` > sessionInfo() R version 3.5.1 (2018-07-02) Platform: x86_64-pc-linux-gnu (64-bit) Running under: Debian GNU/Linux buster/sid

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

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 utils datasets methods base

other attached packages:
[1] DiagrammeR_1.0.0

loaded via a namespace (and not attached):
[1] Rcpp_1.0.0 plyr_1.8.4 pillar_1.3.1 compiler_3.5.1 RColorBrewer_1.1-2 influenceR_0.1.0 bindr_0.1.1
[8] viridis_0.5.1 tools_3.5.1 digest_0.6.18 jsonlite_1.6 viridisLite_0.3.0 gtable_0.2.0 tibble_2.0.1
[15] rgexf_0.15.3 pkgconfig_2.0.2 rlang_0.3.1 igraph_1.2.2 rstudioapi_0.9.0 yaml_2.2.0 bindrcpp_0.2.2
[22] gridExtra_2.3 downloader_0.4 dplyr_0.7.8 stringr_1.3.1 htmlwidgets_1.3 hms_0.4.2 grid_3.5.1
[29] tidyselect_0.2.5 glue_1.3.0 R6_2.3.0 Rook_1.1-1 XML_3.98-1.16 purrr_0.3.0 readr_1.3.1
[36] tidyr_0.8.2 ggplot2_3.1.0 magrittr_1.5 scales_1.0.0 htmltools_0.3.6 assertthat_0.2.0 colorspace_1.3-2
[43] brew_1.0-6 stringi_1.2.4 visNetwork_2.0.5 lazyeval_0.2.1 munsell_0.5.0 crayon_1.3.4

</details>

error: cannot convert ‘v8::Primitive*’ to ‘v8::Object* volatile’ in assignment

I'm receiving the following error when trying to build from source on Linux:

==> devtools::document(roclets=c('rd', 'namespace'))

Updating V8 documentation
Loading V8
Re-compiling V8
'/usr/lib64/R/bin/R' --vanilla CMD INSTALL
'/home/mike/Documents/kaggle/otto/V8'
--library='/tmp/RtmpqDns3X/devtools_install_1eb8118166e6' --no-R --no-data
--no-help --no-demo --no-inst --no-docs --no-exec --no-multiarch
--no-test-load --preclean

  • installing source package ‘V8’ ...
    g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I"/home/mike/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include" -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -c RcppExports.cpp -o RcppExports.o
    ** libs
    g++ -I/usr/include/R/ -DNDEBUG -D_FORTIFY_SOURCE=2 -I"/home/mike/R/x86_64-unknown-linux-gnu-library/3.1/Rcpp/include" -fpic -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4 -c V8.cpp -o V8.o
    V8.cpp: In function ‘void ctx_finalizer(v8::Persistentv8::Context_)’:
    V8.cpp:32:14: error: ‘class v8::Persistentv8::Context’ has no member named ‘Dispose’
    context->Dispose();
    ^
    V8.cpp: In function ‘v8::Handlev8::Script compile_source(std::string)’:
    V8.cpp:40:27: error: ‘New’ is not a member of ‘v8::String’
    Handle source = String::New(src.c_str());
    ^
    V8.cpp: At global scope:
    V8.cpp:46:39: error: ‘Arguments’ does not name a type
    static Handle ConsoleLog(const Arguments& args) {
    ^
    V8.cpp: In function ‘v8::Handlev8::Value ConsoleLog(const int&)’:
    V8.cpp:47:26: error: request for member ‘Length’ in ‘args’, which is of non-class type ‘const int’
    for (int i=0; i < args.Length(); i++) {
    ^
    V8.cpp:48:5: error: ‘AsciiValue’ is not a member of ‘v8::String’
    String::AsciiValue str(args[i]->ToString());
    ^
    V8.cpp:49:20: error: ‘str’ was not declared in this scope
    Rprintf("%s", *str);
    ^
    V8.cpp:52:24: error: too few arguments to function ‘v8::Handlev8::Primitive v8::Undefined(v8::Isolate_)’
    return v8::Undefined();
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:312:28: note: declared here
    friend Handle Undefined(Isolate* isolate);
    ^
    V8.cpp: At global scope:
    V8.cpp:56:40: error: ‘Arguments’ does not name a type
    static Handle ConsoleWarn(const Arguments& args) {
    ^
    V8.cpp: In function ‘v8::Handlev8::Value ConsoleWarn(const int&)’:
    V8.cpp:57:26: error: request for member ‘Length’ in ‘args’, which is of non-class type ‘const int’
    for (int i=0; i < args.Length(); i++) {
    ^
    V8.cpp:58:5: error: ‘AsciiValue’ is not a member of ‘v8::String’
    String::AsciiValue str(args[i]->ToString());
    ^
    V8.cpp:59:43: error: ‘str’ was not declared in this scope
    Rf_warningcall_immediate(R_NilValue, str);
    ^
    V8.cpp:61:24: error: too few arguments to function ‘v8::Handlev8::Primitive v8::Undefined(v8::Isolate
    )’
    return v8::Undefined();
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:312:28: note: declared here
    friend Handle Undefined(Isolate* isolate);
    ^
    V8.cpp: At global scope:
    V8.cpp:65:41: error: ‘Arguments’ does not name a type
    static Handle ConsoleError(const Arguments& args) {
    ^
    V8.cpp: In function ‘v8::Handlev8::Value ConsoleError(const int&)’:
    V8.cpp:66:11: error: request for member ‘Length’ in ‘args’, which is of non-class type ‘const int’
    if(args.Length()){
    ^
    V8.cpp:67:12: error: ‘ThrowException’ is not a member of ‘v8’
    return v8::ThrowException(args[0]);
    ^
    V8.cpp:67:37: error: invalid types ‘const int[int]’ for array subscript
    return v8::ThrowException(args[0]);
    ^
    V8.cpp:69:24: error: too few arguments to function ‘v8::Handlev8::Primitive v8::Undefined(v8::Isolate_)’
    return v8::Undefined();
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:312:28: note: declared here
    friend Handle Undefined(Isolate_ isolate);
    ^
    /usr/include/v8.h: In function ‘ctxptr make_context(bool)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:75:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:79:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
    global->Set(String::NewSymbol("console"), console);
    ^
    V8.cpp:80:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
    console->Set(String::NewSymbol("log"), FunctionTemplate::New(ConsoleLog));
    ^
    V8.cpp:80:76: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handlev8::Value (&)(const int&))’
    console->Set(String::NewSymbol("log"), FunctionTemplate::New(ConsoleLog));
    ^
    V8.cpp:80:76: note: candidate is:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:3696:34: note: static v8::Localv8::FunctionTemplate v8::FunctionTemplate::New(v8::Isolate_, v8::FunctionCallback, v8::Handlev8::Value, v8::Handlev8::Signature, int)
    static Local New(
    ^
    /usr/include/v8.h:3696:34: note: no known conversion for argument 1 from ‘v8::Handlev8::Value(const int&)’ to ‘v8::Isolate_’
    V8.cpp:81:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
    console->Set(String::NewSymbol("warn"), FunctionTemplate::New(ConsoleWarn));
    ^
    V8.cpp:81:78: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handlev8::Value (&)(const int&))’
    console->Set(String::NewSymbol("warn"), FunctionTemplate::New(ConsoleWarn));
    ^
    V8.cpp:81:78: note: candidate is:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:3696:34: note: static v8::Localv8::FunctionTemplate v8::FunctionTemplate::New(v8::Isolate_, v8::FunctionCallback, v8::Handlev8::Value, v8::Handlev8::Signature, int)
    static Local New(
    ^
    /usr/include/v8.h:3696:34: note: no known conversion for argument 1 from ‘v8::Handlev8::Value(const int&)’ to ‘v8::Isolate_’
    V8.cpp:82:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
    console->Set(String::NewSymbol("error"), FunctionTemplate::New(ConsoleError));
    ^
    V8.cpp:82:80: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handlev8::Value (&)(const int&))’
    console->Set(String::NewSymbol("error"), FunctionTemplate::New(ConsoleError));
    ^
    V8.cpp:82:80: note: candidate is:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:3696:34: note: static v8::Localv8::FunctionTemplate v8::FunctionTemplate::New(v8::Isolate_, v8::FunctionCallback, v8::Handlev8::Value, v8::Handlev8::Signature, int)
    static Local New(
    ^
    /usr/include/v8.h:3696:34: note: no known conversion for argument 1 from ‘v8::Handlev8::Value(const int&)’ to ‘v8::Isolate_’
    V8.cpp:85:17: error: ‘NewSymbol’ is not a member of ‘v8::String’
    global->Set(String::NewSymbol("print"), FunctionTemplate::New(ConsoleLog));
    ^
    V8.cpp:85:77: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handlev8::Value (&)(const int&))’
    global->Set(String::NewSymbol("print"), FunctionTemplate::New(ConsoleLog));
    ^
    V8.cpp:85:77: note: candidate is:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:3696:34: note: static v8::Localv8::FunctionTemplate v8::FunctionTemplate::New(v8::Isolate_, v8::FunctionCallback, v8::Handlev8::Value, v8::Handlev8::Signature, int)
    static Local New(
    ^
    /usr/include/v8.h:3696:34: note: no known conversion for argument 1 from ‘v8::Handlev8::Value(const int&)’ to ‘v8::Isolate_’
    V8.cpp:88:46: error: no matching function for call to ‘v8::Context::New(NULL, v8::Handlev8::ObjectTemplate&)’
    lstail->context = Context::New(NULL, global);
    ^
    V8.cpp:88:46: note: candidate is:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5751:25: note: static v8::Localv8::Context v8::Context::New(v8::Isolate_, v8::ExtensionConfiguration_, v8::Handlev8::ObjectTemplate, v8::Handlev8::Value)
    static Local New(
    ^
    /usr/include/v8.h:5751:25: note: no known conversion for argument 2 from ‘v8::Handlev8::ObjectTemplate’ to ‘v8::ExtensionConfiguration_’
    /usr/include/v8.h: In function ‘bool context_enable_typed_arrays(Rcpp::XPtrv8::Persistent<v8::Context >)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:97:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:98:36: error: no matching function for call to ‘v8::Context::Scope::Scope(v8::Persistentv8::Context&)’
    Context::Scope context_scope(ctx);
    ^
    V8.cpp:98:36: note: candidates are:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handlev8::Context)
    explicit V8_INLINE Scope(Handle context) : context
    (context) {
    ^
    /usr/include/v8.h:5849:24: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘v8::Handlev8::Context’
    /usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
    class Scope {
    ^
    /usr/include/v8.h:5847:9: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘const v8::Context::Scope&’
    V8.cpp:99:40: error: base operand of ‘->’ has non-pointer type ‘v8::Persistentv8::Context’
    v8_typed_array::AttachBindings((ctx)->Global());
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h: In function ‘std::string context_eval(std::string, Rcpp::XPtrv8::Persistent<v8::Context >)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:115:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:116:36: error: no matching function for call to ‘v8::Context::Scope::Scope(v8::Persistentv8::Context&)’
    Context::Scope context_scope(ctx);
    ^
    V8.cpp:116:36: note: candidates are:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handlev8::Context)
    explicit V8_INLINE Scope(Handle context) : context
    (context) {
    ^
    /usr/include/v8.h:5849:24: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘v8::Handlev8::Context’
    /usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
    class Scope {
    ^
    /usr/include/v8.h:5847:9: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘const v8::Context::Scope&’
    V8.cpp:123:5: error: ‘AsciiValue’ is not a member of ‘v8::String’
    String::AsciiValue exception_str(exception);
    ^
    V8.cpp:124:34: error: ‘exception_str’ was not declared in this scope
    throw std::invalid_argument(exception_str);
    ^
    V8.cpp:131:5: error: ‘AsciiValue’ is not a member of ‘v8::String’
    String::AsciiValue exception_str(exception);
    ^
    V8.cpp:132:31: error: ‘exception_str’ was not declared in this scope
    throw std::runtime_error(exception_str);
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h: In function ‘bool context_validate(std::string, Rcpp::XPtrv8::Persistent<v8::Context >)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:148:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:149:36: error: no matching function for call to ‘v8::Context::Scope::Scope(v8::Persistentv8::Context&)’
    Context::Scope context_scope(ctx);
    ^
    V8.cpp:149:36: note: candidates are:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handlev8::Context)
    explicit V8_INLINE Scope(Handle context) : context
    (context) {
    ^
    /usr/include/v8.h:5849:24: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘v8::Handlev8::Context’
    /usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
    class Scope {
    ^
    /usr/include/v8.h:5847:9: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘const v8::Context::Scope&’
    /usr/include/v8.h: In function ‘bool context_assign_bin(std::string, Rcpp::RawVector, Rcpp::XPtrv8::Persistent<v8::Context >)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:197:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:198:36: error: no matching function for call to ‘v8::Context::Scope::Scope(v8::Persistentv8::Context&)’
    Context::Scope context_scope(ctx);
    ^
    V8.cpp:198:36: note: candidates are:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handlev8::Context)
    explicit V8_INLINE Scope(Handle context) : context
    (context) {
    ^
    /usr/include/v8.h:5849:24: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘v8::Handlev8::Context’
    /usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
    class Scope {
    ^
    /usr/include/v8.h:5847:9: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘const v8::Context::Scope&’
    V8.cpp:199:41: error: base operand of ‘->’ has non-pointer type ‘v8::Persistentv8::Context’
    v8::Handlev8::Object global = (ctx)->Global();
    ^
    V8.cpp:202:32: error: ‘New’ is not a member of ‘v8::String’
    Localv8::String mystring = v8::String::New((const char
    ) RAW(data), data.length());
    ^
    V8.cpp:203:15: error: ‘NewSymbol’ is not a member of ‘v8::String’
    global->Set(String::NewSymbol(name.c_str()), mystring);
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h: In function ‘Rcpp::RawVector context_get_bin(std::string, Rcpp::XPtrv8::Persistent<v8::Context >)’:
    /usr/include/v8.h:832:13: error: ‘v8::HandleScope::HandleScope()’ is protected
    V8_INLINE HandleScope() {}
    ^
    V8.cpp:214:15: error: within this context
    HandleScope handle_scope;
    ^
    V8.cpp:215:36: error: no matching function for call to ‘v8::Context::Scope::Scope(v8::Persistentv8::Context&)’
    Context::Scope context_scope(ctx);
    ^
    V8.cpp:215:36: note: candidates are:
    In file included from V8.cpp:16:0:
    /usr/include/v8.h:5849:24: note: v8::Context::Scope::Scope(v8::Handlev8::Context)
    explicit V8_INLINE Scope(Handle context) : context
    (context) {
    ^
    /usr/include/v8.h:5849:24: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘v8::Handlev8::Context’
    /usr/include/v8.h:5847:9: note: v8::Context::Scope::Scope(const v8::Context::Scope&)
    class Scope {
    ^
    /usr/include/v8.h:5847:9: note: no known conversion for argument 1 from ‘v8::Persistentv8::Context’ to ‘const v8::Context::Scope&’
    V8.cpp:216:41: error: base operand of ‘->’ has non-pointer type ‘v8::Persistentv8::Context’
    v8::Handlev8::Object global = (ctx)->Global();
    ^
    V8.cpp:219:44: error: ‘NewSymbol’ is not a member of ‘v8::String’
    Localv8::String mystring = global->Get(String::NewSymbol(name.c_str()))->ToString();
    ^
    V8.cpp:221:13: error: ‘class v8::String’ has no member named ‘WriteAscii’
    mystring->WriteAscii((char
    ) res.begin());
    ^
    In file included from V8.cpp:16:0:
    /usr/include/v8.h: In instantiation of ‘static void v8::NonCopyablePersistentTraits::Uncompilable() [with O = v8::Object; T = v8::Context]’:
    /usr/include/v8.h:611:17: required from ‘static void v8::NonCopyablePersistentTraits::Copy(const v8::Persistent<S, M>&, v8::NonCopyablePersistentTraits::NonCopyablePersistent
    ) [with S = v8::Context; M = v8::NonCopyablePersistentTraitsv8::Context; T = v8::Context; v8::NonCopyablePersistentTraits::NonCopyablePersistent = v8::Persistentv8::Context]’
    /usr/include/v8.h:6314:21: required from ‘void v8::Persistent<T, M>::Copy(const v8::Persistent<S, M>&) [with S = v8::Context; M2 = v8::NonCopyablePersistentTraitsv8::Context; T = v8::Context; M = v8::NonCopyablePersistentTraitsv8::Context]’
    /usr/include/v8.h:676:14: required from ‘v8::Persistent<T, M>::Persistent(const v8::Persistent<T, M>&) [with T = v8::Context; M = v8::NonCopyablePersistentTraitsv8::Context]’
    V8.cpp:22:8: required from here
    /usr/include/v8.h:615:5: error: cannot convert ‘v8::Primitive
    ’ to ‘v8::Object
    volatile’ in assignment
    TYPE_CHECK(O, Primitive);
    ^
    /usr/lib64/R/etc/Makeconf:142: recipe for target 'V8.o' failed
    make: *** [V8.o] Error 1
    ERROR: compilation failed for package ‘V8’
  • removing ‘/tmp/RtmpqDns3X/devtools_install_1eb8118166e6/V8’
    Error: Command failed (1)
    Execution halted

Exited with status 1/

Prepare for major upgrade

It looks like Fedora 25 might ship with a new version of libv8 which requires a complete rewrite of the bindings.

Install fails on CentOS 5.5

Hello again,

I'm still working on getting rjade set up but ran into an issue installing the V8 dependency. Here's the R console output:

> install.packages("V8", configure.vars='V8_INCLUDES=/cmap/tools/opt/node-v0.10.24-linux-x64/include/node')
trying URL 'http://cran.mtu.edu/src/contrib/V8_0.6.tar.gz'
Content type 'application/x-gzip' length 110013 bytes (107 KB)
opened URL
==================================================
downloaded 107 KB

* installing *source* package 'V8' ...
** package 'V8' successfully unpacked and MD5 sums checked
** libs
/broad/software/free/Linux/redhat_5_x86_64/pkgs/gcc_4.8.2/bin/g++ -I/xchip/cogs/tools/opt/R-3.1.3/lib64/R/include -DNDEBUG -I/cmap/tools/opt/node-v0.10.24-linux-x64/include/node -I/usr/local/include -I"/xchip/cogs/tools/opt/R-3.1.3/lib64/R/library/Rcpp/include"   -fpic  -g -O2  -c RcppExports.cpp -o RcppExports.o
/broad/software/free/Linux/redhat_5_x86_64/pkgs/gcc_4.8.2/bin/g++ -I/xchip/cogs/tools/opt/R-3.1.3/lib64/R/include -DNDEBUG -I/cmap/tools/opt/node-v0.10.24-linux-x64/include/node -I/usr/local/include -I"/xchip/cogs/tools/opt/R-3.1.3/lib64/R/library/Rcpp/include"   -fpic  -g -O2  -c V8.cpp -o V8.o
/broad/software/free/Linux/redhat_5_x86_64/pkgs/gcc_4.8.2/bin/g++ -I/xchip/cogs/tools/opt/R-3.1.3/lib64/R/include -DNDEBUG -I/cmap/tools/opt/node-v0.10.24-linux-x64/include/node -I/usr/local/include -I"/xchip/cogs/tools/opt/R-3.1.3/lib64/R/library/Rcpp/include"   -fpic  -g -O2  -c v8_typed_array.cpp -o v8_typed_array.o
/broad/software/free/Linux/redhat_5_x86_64/pkgs/gcc_4.8.2/bin/g++ -shared -L/xchip/cogs/tools/opt/R-3.1.3/lib64/R/lib -Bdirect,--hash-style=both,-Wl,-O1 -o V8.so RcppExports.o V8.o v8_typed_array.o -lv8 -L/xchip/cogs/tools/opt/R-3.1.3/lib64/R/lib -lR
/broad/software/free/Linux/redhat_5_x86_64/pkgs/gcc_4.8.2/bin/ld: cannot find -lv8
collect2: error: ld returned 1 exit status
make: *** [V8.so] Error 1
ERROR: compilation failed for package 'V8'
* removing '/xchip/cogs/tools/opt/R-3.1.3/lib64/R/library/V8'

The downloaded source packages are in
    '/tmp/RtmpXVN6IS/downloaded_packages'
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("V8", configure.vars = "V8_INCLUDES=/cmap/tools/opt/node-v0.10.24-linux-x64/include/node") :
  installation of package 'V8' had non-zero exit status

I tried setting V8_INCLUDES such that it points to an existing install of node, and that has the v8.h file, but I'm not sure what -lv8 is or where I might look for it. Any help would be much appreciated and I'm happy to provide any other info that would be helpful. Thanks a lot.

Object function ArrayBuffer() { [native code] } has no method 'isView

I'm trying to use
https://github.com/mapbox/geobuf in V8 and getting the following error.

> fName <- 'https://rawgit.com/benbalter/dc-maps/master/maps/ward-2012.geojson'

> geoJson <- readr::read_file(fName)

> ct <- v8()
> ct$source('inst/htmlwidgets/lib/geobuf/geobuf.js')
[1] "true"

> ct$get(JS('Object.keys(global)'))
 [1] "console"      "print"        "global"       "ArrayBuffer"  "Int8Array"    "Uint8Array"  
 [7] "Int16Array"   "Uint16Array"  "Int32Array"   "Uint32Array"  "Float32Array" "Float64Array"
[13] "DataView"     "geobuf"      

> ct$source('inst/htmlwidgets/lib/geobuf/pbf.js')
[1] "true"

> ct$get(JS('Object.keys(global)'))
 [1] "console"      "print"        "global"       "ArrayBuffer"  "Int8Array"    "Uint8Array"  
 [7] "Int16Array"   "Uint16Array"  "Int32Array"   "Uint32Array"  "Float32Array" "Float64Array"
[13] "DataView"     "geobuf"       "Pbf"  
       
> ct$assign('geojson',geoJson)
> ct$console()
This is V8 version 3.15.11.18. Press ESC or CTRL+C to exit.
~ var gj = JSON.parse(geojson)
~ gj
[object Object]
~ var buf = geobuf.encode(gj,new Pbf())
TypeError: Object function ArrayBuffer() { [native code] } has no method 'isView'
 sessionInfo()
R version 3.3.2 (2016-10-31)
Platform: x86_64-apple-darwin15.6.0 (64-bit)
Running under: OS X El Capitan 10.11.6

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] V8_1.1                  magrittr_1.5            leaflet.extras_0.1.9002
[4] leaflet_1.0.2.9008     

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.8     XML_3.98-1.5    digest_0.6.10   withr_1.0.2     assertthat_0.1 
 [6] bitops_1.0-6    jsonlite_1.1    curl_2.2        devtools_1.12.0 rjson_0.2.15   
[11] tools_3.3.2     RSelenium_1.4.5 readr_1.0.0     htmlwidgets_0.8 RCurl_1.95-4.8 
[16] caTools_1.17.1  memoise_1.0.0   htmltools_0.3.5 tibble_1.2   

Cannot install V8: ANTICONF error

I was trying to update the V8 package from 0.9 to 0.10 on Ubuntu 14.04 (64 bit). Obviously 0.9 was previously installed OK. The update failed with the ANTICONF error.

Package libv8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libv8.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libv8' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lv8
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because libv8 was not found. Try installing:
 * deb: libv8-3.14-dev | libv8-dev (Debian, Ubuntu)
 * rpm: v8-devel (Fedora, EPEL)
 * brew: v8-315 (OSX) -- NOT regular v8! Tap from homebrew/versions
 * csw: libv8_dev (Solaris)
If libv8 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libv8.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------

This behaviour was observed in Rstudio 0.99.876 and 0.99.878 with:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 14.04.3 LTS

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

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

loaded via a namespace (and not attached):
[1] tools_3.2.3

I tried to reproduce the problem in a VM running Ubuntu 15.10. On that machine the V8 package was not installed in R so I installed V8 0.10 directly rather than upgrading from 0.9. This worked OK.

> install.packages("V8")
Installing package into ‘/home/ross/R/x86_64-pc-linux-gnu-library/3.2’
(as ‘lib’ is unspecified)
--2016-02-06 15:08:16--  https://cran.rstudio.com/src/contrib/V8_0.10.tar.gz
...
* installing *source* package ‘V8’ ...
** package ‘V8’ successfully unpacked and MD5 sums checked
Package libv8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libv8.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libv8' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lv8
** libs
rm -f *.o *.so
g++ -I/usr/share/R/include      -I"/home/ross/R/x86_64-pc-linux-gnu-library/3.2/Rcpp/include"  -DV8_DISABLE_DEPRECATIONS -fpic  -O3 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2    -c RcppExports.cpp -o RcppExports.o
...
installing to /home/ross/R/x86_64-pc-linux-gnu-library/3.2/V8/libs
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (V8)

This behaviour was observed in Rstudio 0.99.865 and 0.99.878 with:

> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 15.10

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

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

loaded via a namespace (and not attached):
[1] tools_3.2.3

Since the install worked and the update didn't, I tried uninstalling V8 0.9 on the Ubuntu 14.04 computer and installing V8 0.10. This failed with the same ANTICONF error, so now I don't have an installation of V8 on that computer. I tried installing V8 0.9 from V8_0.9.tar.gz, but that also failed with the same ANTICONF error.

Both the working (Ubuntu 15.10) and failing (Ubuntu 14.04) V8 installation attempts complain that libv8 can't be found, so I investigated further following the helpful information in the ANTICONF message.

  • For both computers I confirmed that libv8-dev is installed (and also tried re-installing it).
  • For both computers I confirmed that pkg-config is installed (and also tried re-installing it).
  • For both computers I confirmed that pkg-config is in one of the directories on PATH and is executable from the command line.
  • For both computers I confirmed that PKG_CONFIG_PATH does not exist as an environment variable.
  • I searched both computers for *.pc files (found 49 and 32 of them) but libv8.pc doesn't exist on either computer.
  • Googling "libv8.pc" only returns a small number of hits, all of them R-related and mentioning the ANTICONF error. None of them points to an actual libv8.pc file. (I am guessing that libv8.pc doesn't actually exist anywhere.)

So, I try to install V8 on two different computers, both complain that libv8 was not found:

Package libv8 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libv8.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libv8' found

but one computer goes on to install it anyway while the other stops with an ANTICONF error. What is the ANTICONF error condition looking for that is true on one computer and false on the other computer?

Also, the ANTICONF error suggests:

you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

Could that message be expanded (or point to an expansion) that indicates how to work out the values for INCLUDE_DIR and LIB_DIR and how to run R CMD INSTALL (I presume there are more arguments needed)?

Thanks.
Ross

Homebrew installation information incomplete

Simply running brew install v8-315 is not always sufficient.

It took me quite some time and effort to figure out that you first have to add a versions tap like so: brew tap homebrew/versions
Only after that I was able to install v8-315 with Homebrew which then allowed me to install the R package.

I suggest you add this information to the instructions where you ask the user to run the brew install v8-315 command.

libc++ too short

Hi,

I am trying to install V8 package on a machine running Manjaro Linux. All is updated.
I get the following error message (either installing from CRAN or github): /lib/libc++.so: file too short.
I have tried to re-install libc++, then compiled it from source but it doesn't solve the issue.

Any idea ?

Thanks

Tab completion

See ?rcompgen. When you press tab, the current buffer gets stored in utils:::.CompletionEnv$token.

Unable to publish app due to V8 error.

V8 install went through successfully, but while publishing an app getting this following error
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded

  • DONE (V8)
    The downloaded source packages are in
    ‘/tmp/RtmpXcaOVl/downloaded_packages’

library(V8)

installed V8 packages
v8-3.14.5.10-25.el7.x86_64
v8-devel-3.14.5.10-25.el7.x86_64

--------
Installing V8 (1.5) ...
01/23 22:39:26.382
curl: (22) The requested URL returned error: 404 Not Found
01/23 22:39:30.252
[1] "Command failed (1)\n\nFailed to run system command:\n\n\t'/opt/microsoft/ropen/3.4.3/lib64/R/bin/R' --vanilla CMD INSTALL '/opt/rstudio-connect/mnt/tmp/RtmplXCmvF/V8' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.4.3' --install-tests --no-docs --no-multiarch --no-demo \n\nThe command failed with output:\n* installing *source* package 'V8' ...\n** package 'V8' successfully unpacked and MD5 sums checked\nUsing PKG_CFLAGS=-I/usr/include/v8-3.14\nUsing PKG_LIBS=-lv8\n------------------------- ANTICONF ERROR ---------------------------\nConfiguration failed because was not found. Try installing:\n * deb: libv8-3.14-dev (formerly: libv8-dev) (Debian, Ubuntu)\n * rpm: v8-314-devel (formerly: v8-devel) (Fedora, EPEL)\n * brew: [email protected] (OSX) -- NOT regular v8! Tap from homebrew/versions\n * csw: libv8_dev (Solaris)\nTo use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:\nR CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'\n--------------------------------------------------------------------\nERROR: configuration failed for package 'V8'\n* removing '/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.4.3/V8'"
01/23 22:39:30.257
Error: Command failed (1)
01/23 22:39:30.257
01/23 22:39:30.257
Failed to run system command:
01/23 22:39:30.257
01/23 22:39:30.257
'/opt/microsoft/ropen/3.4.3/lib64/R/bin/R' --vanilla CMD INSTALL '/opt/rstudio-connect/mnt/tmp/RtmplXCmvF/V8' --library='/opt/rstudio-connect/mnt/app/packrat/lib/x86_64-pc-linux-gnu/3.4.3' --install-tests --no-docs --no-multiarch --no-demo
01/23 22:39:30.257
01/23 22:39:30.257
The command failed with output:
01/23 22:39:30.257
* installing *source* package 'V8' 

v8 version

Any particular reason why v8 version can't be > 3.15 ?

Packaging r-cran-v8 for Debian

Hi,

I have tried to package this project for Debian and ftp-masters rejected because
"V8/inst/doc/v8_intro.html doesn't really look like the preferred form for
modifications"

So please, could you provide the real source of this file?

ANTICONF ERROR: cannot install V8

I'm trying to install V8 rpackage on Ubuntu 18.04.1 LTS.
The version of R used is R 3.5.1.
I proceeded as follows:

  1. I installed libv8 by typing : sudo apt-get install -y libv8-3.14-dev

  2. I type this command to install in R : install.packages("V8")

Then, I received this error:

**** package ‘V8’ correctement décompressé et sommes MD5 vérifiées
Using PKG_CFLAGS=-I/usr/include/v8-3.14
Using PKG_LIBS=-lv8
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because was not found. Try installing:

  • deb: libv8-3.14-dev (formerly: libv8-dev) (Debian, Ubuntu)
  • rpm: v8-314-devel (formerly: v8-devel) (Fedora, EPEL)
  • brew: [email protected] (OSX) -- NOT regular v8! Tap from homebrew/versions
  • csw: libv8_dev (Solaris)
    To use a custom libv8, set INCLUDE_DIR and LIB_DIR manually via:
    R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'

ERROR: configuration failed for package ‘V8’

  • removing ‘/opt/Anaconda/Anaconda3-5.1.0/envs/mro_env/lib/R/library/V8’
  • restoring previous ‘/opt/Anaconda/Anaconda3-5.1.0/envs/mro_env/lib/R/library/V8’
    Warning message:
    In install.packages("/home/ben/Bureau/miniCRAN/src/contrib/V8_1.5.tar.gz", :
    l'installation du package ‘/home/ben/Bureau/miniCRAN/src/contrib/V8_1.5.tar.gz’ a eu un statut de sortie non nul
    **
    I check if i have installed libv8 correctly by typing:
    (mro_env) root@ben-Aspire-E5-575G:/opt/Anaconda/Anaconda3-5.1.0# find /lib* /usr/lib* -name 'libv8'
    /usr/lib/libv8.so
    /usr/lib/libv8.so.3.14.5
    and
    (mro_env) root@ben-Aspire-E5-575G:/opt/Anaconda/Anaconda3-5.1.0# ldconfig -p | grep libv8
    libv8.so.3.14.5 (libc6,x86-64) => /usr/lib/libv8.so.3.14.5
    libv8.so (libc6,x86-64) => /usr/lib/libv8.so
    but when I verify if libv8.pc exists in /usr/lib/pkgconfig/ I didn't find it.

I'm stuck and I do not know how I can solve this problem.

Segfault on make_context

Hi! I run into a segfault while initializing with 'v8()'.

I'm using Archlinux, R 3.3.2 with Intel MKL and V8 3.14.5.7-2. I tested this on a second system with Archlinux, R 3.3.2-2 (Package from Archlinux) and V8 3.14 and V8 3.15 from AUR and get the same results.

I attached debug output from lldb. Any idea how to fix this?

Thanks a lot!

(lldb) target create "/usr/lib64/R/bin/exec/R"
Current executable set to '/usr/lib64/R/bin/exec/R' (x86_64).
(lldb) run
Process 5270 launched: '/usr/lib64/R/bin/exec/R' (x86_64)

R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

NULL
> library(V8)
> v8()
Process 5270 stopped
* thread #1: tid = 5270, 0x00007fffe9b28030 libv8.so`___lldb_unnamed_symbol7623$$libv8.so + 32, name = 'R', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
    frame #0: 0x00007fffe9b28030 libv8.so`___lldb_unnamed_symbol7623$$libv8.so + 32
libv8.so`___lldb_unnamed_symbol7623$$libv8.so:
->  0x7fffe9b28030 <+32>: movq   0x18(%rsi), %rdx
    0x7fffe9b28034 <+36>: movq   (%rsi), %rbx
    0x7fffe9b28037 <+39>: movq   %rdx, %rax
    0x7fffe9b2803a <+42>: movq   %rdx, %rcx
(lldb) bt
* thread #1: tid = 5270, 0x00007fffe9b28030 libv8.so`___lldb_unnamed_symbol7623$$libv8.so + 32, name = 'R', stop reason = signal SIGSEGV: invalid address (fault address: 0x18)
  * frame #0: 0x00007fffe9b28030 libv8.so`___lldb_unnamed_symbol7623$$libv8.so + 32
    frame #1: 0x00007fffe9b280d3 libv8.so`___lldb_unnamed_symbol7624$$libv8.so + 35
    frame #2: 0x00007fffe99d3130 libv8.so`___lldb_unnamed_symbol2390$$libv8.so + 560
    frame #3: 0x00007fffe99d81ea libv8.so`___lldb_unnamed_symbol2447$$libv8.so + 26
    frame #4: 0x00007fffe99dcaa2 libv8.so`___lldb_unnamed_symbol2504$$libv8.so + 962
    frame #5: 0x00007fffe9a43fdc libv8.so`___lldb_unnamed_symbol4366$$libv8.so + 1228
    frame #6: 0x00007fffe9946c4e libv8.so`___lldb_unnamed_symbol82$$libv8.so + 46
    frame #7: 0x00007fffe994aa16 libv8.so`v8::ObjectTemplate::New(v8::Handle<v8::FunctionTemplate>) + 86
    frame #8: 0x00007fffe994ad7b libv8.so`v8::ObjectTemplate::New() + 11
    frame #9: 0x00007fffe9ef1261 V8.so`make_context(bool) + 33
    frame #10: 0x00007fffe9ef0fd2 V8.so`V8_make_context + 130
    frame #11: 0x00007ffff784667c libR.so`___lldb_unnamed_symbol825$$libR.so + 284
    frame #12: 0x00007ffff7808daa libR.so`Rf_eval + 1850
    frame #13: 0x00007ffff7849886 libR.so`___lldb_unnamed_symbol842$$libR.so + 918
    frame #14: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #15: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #16: 0x00007ffff78088c1 libR.so`Rf_eval + 593
    frame #17: 0x00007ffff7806f7b libR.so`___lldb_unnamed_symbol722$$libR.so + 59
    frame #18: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #19: 0x00007ffff7849886 libR.so`___lldb_unnamed_symbol842$$libR.so + 918
    frame #20: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #21: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #22: 0x00007ffff78088c1 libR.so`Rf_eval + 593
    frame #23: 0x00007ffff7849886 libR.so`___lldb_unnamed_symbol842$$libR.so + 918
    frame #24: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #25: 0x00007ffff78062dd libR.so`___lldb_unnamed_symbol715$$libR.so + 1437
    frame #26: 0x00007ffff780af08 libR.so`___lldb_unnamed_symbol727$$libR.so + 5560
    frame #27: 0x00007ffff78087b3 libR.so`Rf_eval + 323
    frame #28: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #29: 0x00007ffff78088c1 libR.so`Rf_eval + 593
    frame #30: 0x00007ffff78062dd libR.so`___lldb_unnamed_symbol715$$libR.so + 1437
    frame #31: 0x00007ffff780af08 libR.so`___lldb_unnamed_symbol727$$libR.so + 5560
    frame #32: 0x00007ffff78087b3 libR.so`Rf_eval + 323
    frame #33: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #34: 0x00007ffff780ac1f libR.so`___lldb_unnamed_symbol727$$libR.so + 4815
    frame #35: 0x00007ffff78087b3 libR.so`Rf_eval + 323
    frame #36: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #37: 0x00007ffff780ac1f libR.so`___lldb_unnamed_symbol727$$libR.so + 4815
    frame #38: 0x00007ffff78087b3 libR.so`Rf_eval + 323
    frame #39: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #40: 0x00007ffff78088c1 libR.so`Rf_eval + 593
    frame #41: 0x00007ffff7806e4f libR.so`___lldb_unnamed_symbol721$$libR.so + 191
    frame #42: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #43: 0x00007ffff7849886 libR.so`___lldb_unnamed_symbol842$$libR.so + 918
    frame #44: 0x00007ffff7808f41 libR.so`Rf_eval + 2257
    frame #45: 0x00007ffff7835317 libR.so`Rf_applyClosure + 999
    frame #46: 0x00007ffff78088c1 libR.so`Rf_eval + 593
    frame #47: 0x00007ffff784b6ee libR.so`Rf_ReplIteration + 558
    frame #48: 0x00007ffff784b47c libR.so`___lldb_unnamed_symbol854$$libR.so + 172
    frame #49: 0x00007ffff787e800 libR.so`run_Rmainloop + 96
    frame #50: 0x000000000040531c R`main + 92
    frame #51: 0x00007ffff6b29291 libc.so.6`__libc_start_main + 241
    frame #52: 0x00000000004051ea R`_start + 42

C++ exception getting lost on OSX R 3.4

This should result in a SyntaxError however it gives unknown reason with the new OSX toolchain.

ctx <- V8::v8()
ctx$eval('var foo = {bla}')
# c++ exception (unknown reason)

This might be due to the libcxx mixing. The problem has appeared in the wild in lawn pkg.

Event Loop

Hello,

So your JS calls R addition works great. Unfortunately the library I'm using is full of Promises. Promises were introduced in es6.

Two solutions could come about...

  1. Add event loop and have JS call a callback to R. Ex:
ct$call_with_callback("fn_that_takes_time", callback = my_R_callback)

or
2. Make Promise objects evaluate immediately. I'm guessing they're trying to evaluate on the next tick, which doesn't currently exist.

Ideas? I could also be using the improperly, so I've attached my files that I use.

Thank you again for your help.

  • Barret

Files used...

test_file.js

import {
  graphql,
  GraphQLSchema,
  GraphQLObjectType,
  GraphQLString
} from 'graphql';


var schema = new GraphQLSchema({
  query: new GraphQLObjectType({
    name: 'RootQueryType',
    fields: {
      hello: {
        type: GraphQLString,
        resolve() {
          return 'world';
        }
      }
    }
  })
});

var gql_test = function() {
  var query = '{ hello }';

  console.log("started")
  var res = graphql(schema, query).then(result => {
    // Prints
    // {
    //   data: { hello: "world" }
    // }
    console.log("returning")
    console.log(result);

  });
  console.log("ended")
  return res;
}

window.schema = schema;
window.gql_test = gql_test;

install script

npm install browserify
npm install babelify
npm install babel-preset-es2015
npm install babel-preset-stage-0

compile script

# global transform needed as ALL code must be es5
./node_modules/.bin/browserify test_file.js -g [ babelify --presets [ stage-0 es2015 ] ] -o ./test_file_bundle.js

R script

ct <- V8::new_context(global = "window");
ct$source("./test_file.js");
ct$console()
# gql_test()
# # started
# # ended
# # [object Promise]

Jquery Integration

Lets say i have a javascript file where jquery i used:

try.js

var object1 = {
  badDay: 0,
};
var object2 = {
  badDay: 99
};
$.extend( object1, object2 );

Note: This is just MVE, the target file has a few hundred lines of code.
My questions is: Can i run try.js via the V8 (R package) or am i right assuming jquery syntax cant be used.
(I am aware jquery is developed for manipulating the DOM of a website and the example above can easily be achieved without jquery. However, I found a useful javascript file (that uses jquery and has a few hundred lines of code) that i successfully integrated in an R Shiny App. Now i wonder, if i would want to run it outside of Shiny (without DOM interaction) would that be possible or not. Therefore, i took a closer look at this v8 package in R.

A bad attempt of trying to source the jquery library:

library(V8)
ctx <- V8::v8()
ctx$source("jquery.min.js") # from "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"
ctx$source("try.js") # see above

As far as i understand jquery is waiting for the DOM to be ready, see e.g. here:
electron/electron#4633 (comment).

Therefore, my question is, if its correct that i cant load/use jquery with the v8-r package.

Some guidance on V8 and JS with R in general

Hi,

This is not an issue but rather a query on how to use the new V8 version to call R functions from within Javascript

I have read the article and loved it and so would like to know how can the new feature be leveraged in my particular case cited below.

I have a shinyapp where I am using a JS charting library. I am computing the data in R and passing it to the Javascript using shinyjs. Shinyjs uses V8. This works great. Now as my data size increase or users from remote geographies try to access my app, I am having to transfer huge datasets from my server.ui to the client-side javascript library and network bandwidth is slowing my app down. I was wondering if I could transfer the entire computation to the client side by enabling the execution of the Rscript functions within JS. Then I can pass the computed data (which I think would now reside on the client-side) directly to the charting library and enable me to bypass the transfer of heavy data between server and the client. Let me know if I am making sense so far or I am conceptually inaccurate (which can well be the case given my limited knowledge in this field).

So, if the above theory makes sense, I would like to run the R functions from a particular package within JS.

Current Scenario:

  1. When app loads, the R script pulls an initial data set and passes it to the JS charting library using shinyJS. This is when the initial transfer of data between server and client takes place and this cannot be avoided.
    Say the initial data is a data frame DF.
    DFJson <- jsonlite::toJSON(DF)
    Now pass this json to the JS charting library
  2. For subsequent calculations based on users input, all I need to do is use the same json which I have passed onto the JS and run some R functions on it and then pass it back to the charting library. In the current scenario, I am computing the revised data within R and passing it back to JS
DF<-newDF(DF)
DFJson <- jsonlite::toJSON(DF)
newDF<-function(data){
#convert the data frame to xts
data<-as.xts(data)
SMA<-quantmod::SMA(data,20)
data<-merge(data,SMA)
#convert it back to data frame
data<-as.data.frame(Date=index(data),coredata(data))
return(data)
}

Now this new data with an additional column is being transferred to the JS library. This time again the transfer between server and client is subject to network bandwidth. I would like to bypass these subsequent transfers by computing the new data within JS using the R function newDF that I have defined. Please note that DF has dependency on the R library quantmod.

  1. Do I make sense at all.
  2. If yes, can I perform the above strategy using the new V8.
  3. Do I need to place my function newDF within gloabl.R
  4. Appreciate a small example of writing newDF within JS using v8 console.R API

Regards
SD

access to window object

I am really ignorant here, but would it be possible to implement a solution to window like this article presents? I assume this will allow access to quite a few js libraries, such as d3, etc.

Installation on Ubuntu

The libv8-dev suggested in the installation instructions is out of date -- it is still using V8 3.14.5. I can't seem to install an updated version of the R V8 on Ubuntu.

Implement console

It would be really cool if console.log and console.error could call back to Rprintfand Rf_error. That way we can use the jsforcats tutorial inside R :)

Maybe this example is helpful. Also here where it says: The following code provides an example of creating a template for the global object and setting the built-in global functions.

Migration to V8 LTS 6.x / 7.x

New version of V8 should work with libv8 version 6 or 7 as provided by e.g nodejs 10.15 LTS. Work is currently in the newapi branch. To test this:

  • MacOS: brew install v8
  • Debian buster: apt-get install libnode-dev
  • Fedora: yum install v8-devel

And then:

remotes::install_github("jeroen/V8")

Outstanding issues:

winbuilder

Doesn't build on winbuilder because TryAcquireSRWLockExclusive() is not available on vista.

Fixed by reverting win7 patch: https://github.com/rwinlib/libv8/tree/v6.2.414.50-vista

dagitty

Fixed: turns out this package is sensitive to locale and ICU config.

On MacOS v8::V8::InitializeICUDefaultLocation() is needed to initiate the ICU data. On Debian it works with libnode-dev if we make sure the locale is set to UTF-8:

sudo apt-get install locales
localedef -i en_US -f UTF-8 en_US.UTF-8
export LANG=en_US.UTF-8
R CMD check dagitty_0.2-2.tar.gz

Example code:

ctx <- dagitty:::.getJSContext()
ctx$eval('var y1 = "pdag{ {i j} -> x -> {a -- b -- c -- a } a -> z b -> y x[e] y[o] }"')
ctx$eval('GraphParser.parseGuess(global.y1).toString()')

dqshiny

Fix is on CRAN

jsonld

Fix is on CRAN

lawn

Fix on CRAN.

invoke R

Hello!

I'm curious if it is possible to have V8 invoke R.

Situation. I have a "render" function. This function needs time sensitive context within R. When this javascript render function is executed, it will call R which will then return a json blob that the js can understand.

I know this is possible with C. Didn't know if it could be possible with the V8 context.

Thank you,
Barret

error in evaluating JavaScript String fromCharCode() Method

I'm trying to use this function in R. I'm trying to convert Unicode values into characters. One workaround i used is using V8 package as follows :

library(V8)
ct <- v8()
ct$eval("var res = String.fromCharCode(55357);")

But when ct$get("res") is called it throws following error :

Error in file.exists(txt) : 
  file name conversion problem -- name too long?

I want to save the value of res to file but as long as it throws error, output can't be redirected.

knitr engine to run JS programs

It would be helpful if V8 provided a knitr engine so that JavaScript code blocks in R Markdown documents could be executed locally and immediately using Node libraries, rather than by a browser/in a web page. reticulate defines its own engine for executing Python chunks; it seems like V8 could do something similar (?).

Note that there is a node engine listed in https://bookdown.org/yihui/rmarkdown/language-engines.html, which according to Yihui essentially runs code using system('node -e CODE').

Fatal error on Arch Linux

Running

context <- V8::v8()

i get

# Fatal error in ../src/platform-linux.cc, line 776
# CHECK_EQ(0, result) failed
#   Expected: 0
#   Found: 22

and the R session crashes. I am running Antergos (Arch Linux) and have installed the v8-3.14 package.

Here is my session info:

R version 3.5.1 (2018-07-02)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Antergos Linux

Matrix products: default
BLAS/LAPACK: /usr/lib/libopenblas_haswellp-r0.3.4.so

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

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

other attached packages:
[1] V8_1.5        usethis_1.4.0

loaded via a namespace (and not attached):
[1] compiler_3.5.1 tools_3.5.1    parallel_3.5.1 fs_1.2.6       glue_1.3.0     curl_3.2       yaml_2.2.0     Rcpp_1.0.0     jsonlite_1.6

V8 broken in Fedora 25

Fedora 25 ships with 5.2, so tools/version.cpp wrongly shows ANTICONF ERROR on source install. Error message not displayed from tools/version.cpp.

On Fedora 25, you need to install v8-314-devel, which clashes with v8-devel (so other software may get broken), and needs:

--configure-vars='INCLUDE_DIR=/usr/include/v8-3.14 LIB_DIR=/usr/lib64'

SyntaxErrors

Dear Jeroen,

I followed your suggestions on NPM and the V8 package: bundling it with browserify.
I tried to do the same with the neataptic package.
However, when sourcing in R, I get a syntax error:

Error in context_eval(join(src), private$context) : 
  SyntaxError: Unexpected token ;

Before using browserify, I tried to source it directly from the browser distribution found here. However, I get another syntax error:

Error in context_eval(join(src), private$context) : 
  SyntaxError: Unexpected token this

I presume something is wrong with parsing, but the javascript is technically valid.

Best,

Gynt

source method not loading correctly a script

Hi @jeroenooms

First of all, thanks for this package! It rocks!

I have a problem. I'm trying to load and library (https://github.com/nmrugg/stockfish.js) in a context:

library("V8")
ct <- new_context()
ct$source("stockfish.js") # no error
ct$eval("var stockfish = STOCKFISH();") 

And i get:

Error: ReferenceError: setTimeout is not defined

I guess the problem is because the file (stockfish.js) is too big and minified, but im not sure (or the error is becuse I'm using windows 😟). Do you have any idea what is happening?

I can replicate with no problem in a html file:

 <script src="stockfish.js"></script>
  <script>
    var stockfish = STOCKFISH();
    stockfish.onmessage = function(event) { console.log(event.data ? event.data : event);};
    stockfish.postMessage("go depth 2");
    stockfish.postMessage("position fen r3kb1r/1pBnp1pp/p4p2/1N1n1b2/2BP4/5NP1/P4P1P/R1R3K1 w kq - 0 17");
    stockfish.postMessage("go depth 5");
  </script>

Thank again for your work!

Including full libv8 source?

As V8 is written in C++, is there a reason the full source can't be included in the package, rather than requiring libv8 as a system dependency? It seems the libv8 BSD-3 license would allow this. Is it a CRAN issue?

Any way to hold a V8 context in package namespace?

I put a js_context <- V8::new_context(global = "window") in the package namespace. But when I use it in a package function, an error occurs saying

Error: Context has been disposed. 

Is there a way to hold a V8 context to avoid repeatedly creating a new context with the same script sourced every time?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.