plots and Rapache

256 views
Skip to first unread message

LJ Perovich

unread,
Jun 29, 2010, 3:07:53 PM6/29/10
to rapache
Hi everyone,

After some tinkering I've got Rapache (mostly!) up and running (R
2.11.0; Apache 2.2.3; CentOS 5). It's really great and basic
operations and input forms seem to be working well, but I'm running
into problems when I try to include plots. My impression from the
examples and discussion is that plots rely on the Cairo (or previously
GDD) library. Is this correct?

Acting under this assumption, I've tried to install Cairo through R
with the command: install.packages('Cairo',lib='/usr/lib/R/library').
This command worked for other packages (brew, ggplot2) but in this
case gives the error and output:

################################################################
trying URL 'http://software.rc.fas.harvard.edu/mirrors/R/src/contrib/
Cairo_1.4-5.tar.gz'
Content type 'application/x-gzip' length 75318 bytes (73 Kb)
opened URL
==================================================
downloaded 73 Kb

* installing *source* package 'Cairo' ...
sh: ./configure: /bin/sh: bad interpreter: Permission denied
ERROR: configuration failed for package 'Cairo'
* removing '/usr/lib/R/library/Cairo'

The downloaded packages are in
'/tmp/RtmpEaI8uF/downloaded_packages'
Updating HTML index of packages in '.Library'
Warning message:
In install.packages("Cairo", lib = "/usr/lib/R/library") :
installation of package 'Cairo' had non-zero exit status
################################################################


I've also tried installing using R CMD INSTALL but get a similar
error. Based on the content of the error, I tried testing out the
permissions as as suggested here: http://www.mail-archive.com/r-d...@r-project.org/msg17561.html.
Briefly:


################################################
Created sh script called /tmp/junk.sh containing
#!/bin/sh
echo Hello at `date`

Run:
chmod +x /tmp/junk.sh
sh -c /tmp/junk.sh

Output:
-bash: /tmp/junk.sh: bin/sh: bad interpreter: Permission denied
##############################################

This output seems consistent with the library installation error, so
maybe this is my problem? Unfortunately, I'm not sure how to fix
this. I've tried chmod 1777 /tmp before installing Cairo, but no
change in outcome. The previously mentioned post seems to recommend
changing the fstab file, but my /etc/fstab file is fairly minimal,
containing only:
none /dev/pts devpts rw 0 0
Because it didn't seem to include the /tmp has noexec mentioned in the
post, I wasn't sure what change and so left it alone. Is there
something I should add or change here?

In short, are my plotting problems likely caused by the lack of the
Cairo library? If so, how might I change the permissions (or
something else?) in order to install it?

Thanks,
LJ

Jack Tanner

unread,
Jun 29, 2010, 4:51:20 PM6/29/10
to rap...@googlegroups.com
LJ, it does sound like a permissions problem. Note that the location to
which you're installing cairo - /usr/lib/R/library - is not the same as
where you tried to relax permissions - /tmp. Note further that it's not
a good idea to make /usr/lib/R/library world-writeable. My advice is to
become root in order to install cairo, i.e.,

$ su -
$ R
> install.packages ...

Jeroen Ooms

unread,
Jun 30, 2010, 5:38:06 AM6/30/10
to rap...@googlegroups.com, pero...@silentspring.org
I've had the same problem a few times. It happens when your R tmp dir is not writable, which again might happen if you are on a shared VPS. Try changing R's temp dir:

mkdir /Rtmp
chmod +t,ugo+rwx /Rtmp

export TMP=/Rtmp

Now everything should work fine.



--
You received this message because you are subscribed to the Google Groups "rapache" group.
To post to this group, send email to rap...@googlegroups.com.
To unsubscribe from this group, send email to rapache+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rapache?hl=en.


LJ Perovich

unread,
Jul 1, 2010, 4:53:59 PM7/1/10
to rapache
Thanks for your help! Your advice plus some additional installations
got Cairo installed and working in R. Unfortunately I'm still
struggling to put together my first plot. My code is as follows:

<html>
<body>
<%
library(Cairo)
plotdir='http://70.32.83.100/img/'
filename<-paste(plotdir, "plotform.png", sep="")
Cairo(file=filename, type="png")
plot(1:5, rep(5, 5))
dev.off()
%>
<img src="<%=filename%>"/>
</body>
</html>

I believe the code is getting processed correctly through brew, as
adding something like a<-2+3 to the <% %> section and <%=print(a)%> to
the html gives the expected result. Also, the path to the file seems
to be valid, since I can see the dummy image I placed at the location
given by printing filename.

I'm wondering now if it's a problem similar to the one Maurits ran
into in the "RApache error RApache Warning/Error!!! ParsedFile Any
suggestions?" thread, but unfortunately I haven't been able to
successfully apply the advice given there. I created a dummy png file
at the filename path as suggested and changed the permissions to be
readable and writable to all through: chmod a+rwx plotform.png. I
also tried changing the ownership and group of the file through:
chown apache plotform.png
chgrp apache plotform.png
but no change in result. Now I've been trying to set the virtual host
rights to ensure that apache can read and write, but I'm not quite
sure how to go about this (or if this is even the problem!). I do
have within the httpd.conf file:
User: apache
Group: apache

Other than that I wasn't sure where to start... this may be more of a
Linux question, but any help would be much appreciated!

Thanks,


On Jun 30, 5:38 am, Jeroen Ooms <jeroen.o...@stat.ucla.edu> wrote:
> I've had the same problem a few times. It happens when your R tmp dir is not
> writable, which again might happen if you are on a shared VPS. Try changing
> R's temp dir:
>
> *mkdir /Rtmp
> chmod +t,ugo+rwx /Rtmp*
> *export TMP=/Rtmp*
> *
> *
> Now everything should work fine.
> *
> *
> *
> *
> >> http://www.mail-archive.com/r-de...@r-project.org/msg17561.html.
> > rapache+u...@googlegroups.com<rapache%2Bunsu...@googlegroups.com>
> > .

Laura Perovich

unread,
Jul 22, 2010, 11:00:08 PM7/22/10
to rapache
Hi everyone,

Just wanted to send an update on the solution to my plotting problems, in case anyone else ever encounters something similar.  It turned out to be partly an Apache write permissions issue and partly an incorrect file path issue.  I solved the permissions by some combination of:
--running Apache as FastCGI to resolve the permission errors (as by http://wiki.mediatemple.net/w/Running_Apache_as_FastCGI_on_your_%28dv%29,_resolving_Apache_permission_errors)
--adding apache to the psacln group and changing the group of the html and img files to psacln (as by http://wiki.mediatemple.net/w/Working_around_permissions_issues_on_the_%28dv%29_Dedicated-Virtual)

I realize some of these links may be specific to my setup, but hopefully they can provide some insight as to a starting point for others!

After this was changed, I also had to fix a mistake in my file paths--specifically switch the file path within the R code to something like /var/www/vhosts/mydomain/httpdocs/img/filename.jpg while leaving the html image path at http://70.32.83.100/img/filename.jpg.  Thanks to Maurits for pointing this out to me!
> To unsubscribe from this group, send email to rapache+u...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages