hordes icon indicating copy to clipboard operation
hordes copied to clipboard

Error with `hordes_init()`

Open emmansh opened this issue 3 years ago • 2 comments

I successfully installed hordes module from npm, but having an error at a very fundamental stage.

// in nodeJS
const { library, hordes_init } = require('hordes');
hordes_init();

Also, just to be on the safe side, I also installed Rserve package from CRAN on R such that:

install.packages("Rserve")

Then closed R and ran the js script from above. I get the following error in console:

node:events:368 throw er; // Unhandled 'error' event ^

Error: spawn R ENOENT at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) Emitted 'error' event on ChildProcess instance at: at Process.ChildProcess._handle.onexit (node:internal/child_process:288:12) at onErrorNT (node:internal/child_process:477:16) at processTicksAndRejections (node:internal/process/task_queues:83:21) { errno: -4058, code: 'ENOENT', syscall: 'spawn R', path: 'R', spawnargs: [ 'CMD', 'Rserve', '--vanilla', '--RS-port', 6311 ] }

Any idea why?

emmansh avatar Jan 31 '22 11:01 emmansh

Hey,

npm install hordes will install RServer so you do not need to reinstall it :) => https://github.com/ColinFay/hordes/blob/master/install.R#L14

Can you run Rserve from your command line?

Rserve --vanilla --RS-port 6311

I suppose hordes_init() should perform a check to see if the Rserve bin is available.

ColinFay avatar Jan 31 '22 12:01 ColinFay

Thanks! Well here is the thing... if I just open command line (CMD on Windows 11), and run

Rserve --vanilla --RS-port 6311

It works as I get:

Rserve: Ok, ready to answer queries.

However, if I run the same line from within the project directory (i.e., in VS Code terminal) I get:

Rserve : The term 'Rserve' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Rserve --vanilla --RS-port 6311 + ~~~~~~ + CategoryInfo : ObjectNotFound: (Rserve:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException


EDIT


I need to refine my point from above. The Rserve command works even if I navigate to the folder of the project from outside. Meaning that I open CMD and then navigate, and then use Rserve command:

cd C:\Users\blah\foo\bar_dir

cd C:\Users\blah\foo\bar_dir> Rserve
Rserve: Ok, ready to answer queries.

By contrast, typing Rserve from VS Code where my node app is at, throws the error as in above.

Screenshot 2022-01-31 150338

emmansh avatar Jan 31 '22 12:01 emmansh