JS engine "" not available in the system


(Nic Hubbard) #1

Matrix Version: 5.4.3.1

I am wanting to use ssjs but am getting this error:

JS engine “” not available in the system.

We use Ubuntu, is there a package that needs to be installed for this to work? Obviously I Googled this, but wanted to know what specifically Matrix is wanting.


(David Schoen) #2

The preference would be to use V8JS as this exposes a JS engine directly within PHP that’s fairly secure by default.

Alternatively we’ve run SpiderMonkey via shelling out to the binary previously (configured in tools.inc, still works in 5.4.3.1) - just be careful if you go this route that the binary exposed to Matrix doesn’t have any file system, system or network functionality enabled, if it does that functionality will be accessible by any author.


(Nic Hubbard) #3

I installed the v8 package on Ubuntu, but do I need to tell Matrix where that is? I still get the warning about the JS engine not being available.


(David Schoen) #4

V8 and V8JS are separate.

V8 is the JS engine and V8JS is the PHP PECL code that needs to be loaded by php before Matrix runs. V8JS needs V8 to be available to compile against.

If you’ve got it loading up in php correctly, this should work:

# php -r '(new V8Js)->executeString("print(\"Hello from V8\\n\")");'
Hello from V8

Once that works you’ll need to either restart php-fpm or reload your web server if you’re not using FPM.

What version of PHP are you running?

In PHP 5.6 we run V8 3.14.5.10 with V8JS 0.1.3 - we’re running a much newer V8 and V8JS in newer versions of PHP, but we haven’t made a release of Matrix that supports that yet.

Edit: p.s sorry, I’m not sure how to get V8JS running under Ubuntu, I know we had a lot of “fun” getting it working in EL.


(Nic Hubbard) #5

Thanks, I got it working. :slight_smile:


(Tbaatar) #6

Hi,

Can you share the process installing V8 to Matrix.
I’m getting nowhere on Debain 8 :(.

UPDATE:

Managed to install V8 and printing the ‘Hello from V8’ mesage in terminal, and restarted the apache web server but still getting ‘Warning: V8 is not installed on the system. JavaScript processing will not work.’ message.

Is there anything else I need to configure?

UPDATE:2
Got it installed. Forgot to add the V8js extension to php.ini file.
Weeeee.

Basically, ran apt-cache search libv8 to see all available v8 engines for debain 8, then ran:

  • apt-get install libv8-3.14-dev libv8-3.14-dbg g++ cpp
  • sudo pecl install v8js-0.1.3
  • edited php.ini and added extension=v8js.so

(Nic Hubbard) #7

Thanks for the update. I honestly couldn’t remember what I had done. Probably should have documented it. :slight_smile:


(Tbaatar) #8

Hi David,

Which versions of V8 and V8js do you recommend installing for php7.1?

Many thanks.


(David Schoen) #9

php -i ends up reporting:

v8js

V8 Javascript Engine => enabled
V8 Engine Compiled Version => 6.4.0
V8 Engine Linked Version => 6.4.0 (candidate)
Version => 1.4.1

So that’ll be V8JS 1.4.1 and V8 6.4.0, but if you’re not running an Enterprise Linux like CentOS, whatever compiles in your environment and passes its own internal tests should work ok (Matrix doesn’t directly use any particularly advanced features of either V8 or V8JS).