SpiderMonkey: the R package

If you need to evaluate code written in javascript from within R, the package SpiderMonkey is what you want. Installing it is non-trivial, which is why I publish instructions here. (The instructions are known to work on Debian/Wheezy, but should be easy to adopt to other distributions as well.)

Current status: the final build fails.

Install the source code of the java-script interpreter SpiderMonkey.

mkdir ~/mozilla
cd ~/mozilla
wget http://ftp.mozilla.org/pub/mozilla.org/js/js185-1.0.0.tar.gz
tar -xzf js185-1.0.0.tar.gz

Install autoconf version 2.13 (no later version!)

apt-get install autoconf2.13

Build the java-script interpreter SpiderMonkey.

cd js-1.8.5/js/src
autoconf2.13
./configure
make

Install the java-script interpreter

As root, run

make install

Install the R package SpiderMonkey

export SPIDER_MONKEY=~/mozilla/js-1.8.5/js/src/
R --no-save "install.packages('SpiderMonkey', repos = 'http://www.omegahat.org/R')

Unfortunately, this fails with

* installing *source* package ‘SpiderMonkey’ ...
configure: creating ./config.status
config.status: creating src/Makevars
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/home/hans/mozilla/js-1.8.5/js/src/ -I/home/hans/mozilla/js-1.8.5/js/src//Linux_DBG.OBJ     -fpic  -O3 -pipe  -g  -c jserrorReporter.c -o jserrorReporter.o
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -I/home/hans/mozilla/js-1.8.5/js/src/ -I/home/hans/mozilla/js-1.8.5/js/src//Linux_DBG.OBJ     -fpic  -O3 -pipe  -g  -c jsval.c -o jsval.o
jsval.c: In function ‘jsval_to_double’:
jsval.c:35:24: error: invalid type argument of unary ‘*’ (have ‘jsdouble’)
jsval.c: In function ‘jsval_to_string’:
jsval.c:48:5: warning: implicit declaration of function ‘JS_GetStringBytes’ [-Wimplicit-function-declaration]
jsval.c:48:9: warning: assignment makes pointer from integer without a cast [enabled by default]
jsval.c: In function ‘js_to_R’:
jsval.c:71:28: error: invalid type argument of unary ‘*’ (have ‘jsdouble’)
make: *** [jsval.o] Fel 1
ERROR: compilation failed for package ‘SpiderMonkey’
* removing ‘/usr/local/lib/R/site-library/SpiderMonkey’

The downloaded source packages are in
        ‘/tmp/Rtmp57LjXA/downloaded_packages’
Warning message:
In install.packages("SpiderMonkey", repos = "http://www.omegahat.org/R") :
  installation of package ‘SpiderMonkey’ had non-zero exit status

References

comments powered by Disqus


Back to the index

Blog roll

R-bloggers, Debian Weekly
Valid XHTML 1.0 Strict [Valid RSS] Valid CSS! Emacs Muse Last modified: oktober 17, 2019