Code Monkey home page Code Monkey logo

Comments (11)

s-u avatar s-u commented on June 11, 2024

Ideally, you should use R CMD to setup the environment, so if let's say if you are running

sh startme.sh

then for Java to work you'd run

R CMD sh startme.sh

instead. Alternatively, whatever you're starting can use R CMD sh -c set to get all the necessary R environment variables.

from rapache.

jeroen avatar jeroen commented on June 11, 2024

We should probably do this before our call to Rf_initEmbeddedR at https://github.com/jeffreyhorner/rapache/blob/master/mod_R.c#L973-L1010

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 11, 2024

What's happening is that the linux service script(unity, init, system, etc.) ought to be amended to update the LD_LIBRARY_PATH (And other side effects of R CMD sh) prior to starting the server. Typically, the service script runs in a minimal environment.

I've known about this issue for a long time, but I'm not sure the best way to fix it.

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 11, 2024

Here's a version of the init script that ultimately get's placed into /etc/init.d/apache2 on ubuntu:

http://bazaar.launchpad.net/~ubuntu-branches/ubuntu/vivid/apache2/vivid/view/head:/debian/apache2.2-common.apache2.init

It references a file that's typically located at /etc/apache2/envvars

Maybe we need an additional config tool that outputs the side effects of R CMD sh and update that!

from rapache.

jeroen avatar jeroen commented on June 11, 2024

Modifying global apache configs is difficult to setup and sound dangerous, especially if people are running other (non-R) websites on the same apache box.

Can we just output the variables we need to a file and run base::readRenviron() to source them? Or is there more to it than setting environment variables?

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 11, 2024

You'll see in the /etc/init.d/apache2 script that the environment has to be set up at the invocation of apachectl. The facility for setting up that enviroment seems to be defined by the content of /etc/apache2/envvars, which would affect all the sites including non-R sites.

from rapache.

jeffreyhorner avatar jeffreyhorner commented on June 11, 2024

Something like this would populate the R environment to /etc/apache2/envvars:

#!/bin/bash
# save this to /tmp/exportenv.sh
for i in `env`; do
   echo export $i
done

Then run

/usr/bin/env -i R CMD sh /tmp/exportenv.sh >> /etc/apache2/envvars

But this doesn't solve it completely as there are some env vars that contain spaces like:

LN_S=ln -s

So that shows up as two lines in the /etc/apache2/envvars like this:

export LN_S=ln
export -s

And then there are other strange env vars like:

export _=/usr/bin/env

from rapache.

jeroen avatar jeroen commented on June 11, 2024

I really don't like hardcoding that stuff in /etc/apache2/envvars. It becomes a mess when you upgrade R and then need to re-do this stuff. I guess I need to hack a runtime solution.

from rapache.

jeroen avatar jeroen commented on June 11, 2024

What I don't understand is what R CMD sh does beyond the things in /usr/lib/R/etc/ldpaths ?

from rapache.

alexvpickering avatar alexvpickering commented on June 11, 2024

Just confirming that I was able to solve the same issue by adding export LD_LIBRARY_PATH=/usr/lib/jvm/default-java/jre/lib/amd64/server (directory with libjvm.so - can differ) to /etc/apache2/envvars.

Another issue arose however from the same rJava-dependent function call (mailR::send.mail) which works fine as user www-data from the terminal. No response is received and the apache2 logs show:

[Sat Jan 20 08:03:11.177569 2018] [:error] [pid 3967:tid 140146487838464] [client 192.168.1.67:41784] rApache Notice! *** stack smashing detected ***: /usr/sbin/apache2 terminated [Sat Jan 20 08:03:11.932544 2018] [core:notice] [pid 24498:tid 140146758621056] AH00051: child pid 3967 exit signal Aborted (6), possible coredump in /etc/apache2

from rapache.

jeroen avatar jeroen commented on June 11, 2024

@alexvpickering I have never seen this stack smashing detected error. If you can reproduce it you can open a separate issue.

from rapache.

Related Issues (20)

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.