## WeBWorK Main Forum

### Problems with R in 2.13

by Ted Boggs -
Number of replies: 6
I am trying to get R working in version 2.13 for a professor at my school. I am a Linux Sysadmin, and not an educator. I also did not do the initial installation of WeBWorK, so I have come late to the game.

I believe I have followed the instructions correctly for setting up R per the Wiki.

The server is running Red Hat Enterprise Linux Server release 7.4 (Maipo).

The R Server appears to be functioning normally:

# telnet localhost 6311
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Rsrv0103QAP1

--------------

I have tried multiple values for the R configuration. If I put in the PG macro verbatim, I get this error with the example problem:

## WeBWorK Warnings

WeBWorK has encountered warnings while processing your request. If this occured when viewing a problem, it was likely caused by an error or ambiguity in that problem. Otherwise, it may indicate a problem with the WeBWorK system itself. If you are a student, report these warnings to your professor to have them corrected. If you are a professor, please consult the warning output below for more information.

### Warning messages

• ERRORS in rendering problem: 1 |Library/UBC/STAT/STAT300/hw07/stat300_hw07_q01.pg| ERRORS from evaluating PG file: connect: Permission denied at line 129 of [PG]/macros/RserveClient.pl
• Died within Carp::croak called at line 27 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::fh called at line 323 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::_send_command called at line 234 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::eval called at line 129 of [PG]/macros/RserveClient.pl
• from within main::rserve_start called at line 47 of (eval 837)

• ERRORS in rendering problem: 2 |Library/UBC/STAT/STAT300/hw07/stat300_hw07_q02.pg| ERRORS from evaluating PG file: connect: Permission denied at line 129 of [PG]/macros/RserveClient.pl
• Died within Carp::croak called at line 27 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::fh called at line 323 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::_send_command called at line 234 of /usr/local/share/perl5/Statistics/R/IO/Rserve.pm
• from within Statistics::R::IO::Rserve::eval called at line 129 of [PG]/macros/RserveClient.pl
• from within main::rserve_start called at line 50 of (eval 1133)
If I change the macro to be $pg{specialPGEnvironmentVars}{Rserve} = {"localhost"}; instead, I do not get the error, but the scatterplots do not render, and on other problems utilizing R, I get this error: ### PG question processing error messages ### PG warning messages ------ Calling main::rserve_start is disabled unless Rserve host is configured in$pg{specialPGEnvironmentVars}{Rserve}{host}

------
Calling main::rserve_eval is disabled unless Rserve host is configured in $pg{specialPGEnvironmentVars}{Rserve}{host} ------ Calling main::rserve_eval is disabled unless Rserve host is configured in$pg{specialPGEnvironmentVars}{Rserve}{host}

------
Calling main::rserve_eval is disabled unless Rserve host is configured in $pg{specialPGEnvironmentVars}{Rserve}{host} ------ Calling main::rserve_eval is disabled unless Rserve host is configured in$pg{specialPGEnvironmentVars}{Rserve}{host}

------
Calling main::rserve_eval is disabled unless Rserve host is configured in $pg{specialPGEnvironmentVars}{Rserve}{host} ------ Calling main::rserve_eval is disabled unless Rserve host is configured in$pg{specialPGEnvironmentVars}{Rserve}{host}

------
Calling main::rserve_eval is disabled unless Rserve host is configured in $pg{specialPGEnvironmentVars}{Rserve}{host} or other similar errors. Any idea what might be causing these errors? Thanks, Ted In reply to Ted Boggs ### Re: Problems with R in 2.13 by Wesley Burr - Hi, Ted, I just went through a similar troubleshooting path: http://webwork.maa.org/moodle/mod/forum/discuss.php?d=4320. It sounds like you haven't done the configuration step to set the specialPGEnvironmentVars Rserve variable, which is listed in the wiki article. I've copied it below to save you a step. The file should be at /opt/webwork/webwork2/conf/localOverrides.conf. Just edit it (as root), reboot Apache, and check again. ### Configure Webwork with the location of the R server PG macros that communicate with R need to know the location of the R server, which is a URL . You can do this by modifying "${WW_PREFIX}/webwork2/conf/defaults.conf", but since it's a local configuration, you should put it in localOverrides.conf:

\$pg{specialPGEnvironmentVars}{Rserve} = {host => "localhost"};
In reply to Wesley Burr

### Re: Problems with R in 2.13

by Wesley Burr -
Upon a more careful read (I missed the line in the middle of your post) I see you did try that configuration. So Danny's suggestion is more probable, please ignore my attempt at help.
In reply to Wesley Burr

### Re: Problems with R in 2.13

by Ted Boggs -
Thanks, Wesley. I've tried several different permutations of that macro, but to no avail. If you think of anything else, please let me know.
In reply to Ted Boggs

### Re: Problems with R in 2.13

by Danny Glin -
The "permission denied" message makes me think it could be a file permissions issue, or (more likely in my mind) an issue with SElinux.

Is SElinux enabled on your system? If so, have you allowed connections to the R server in SElinux?
In reply to Danny Glin

### Re: Problems with R in 2.13

by Ted Boggs -
Hi Danny,

Yes, I thought SElinux a likely culprit as well. I tried permissive previously, but nothing was logged. After seeing your reply, I decided to disabled to see if it will work at all, and it seems to have solved the issue. Is there any documentation available on how to make WeDWorK work with SElinux?

Thanks,
Ted
In reply to Ted Boggs

### Re: Problems with R in 2.13

by Danny Glin -
I'm not sure if anyone has tried running WeBWorK with SElinux. On my systems I disable it, and I believe the WeBWorK install script does as well.