Error: .onLoad failed in loadNamespace()

3,387 views
Skip to first unread message

Patrick Toche

unread,
Dec 3, 2013, 6:17:50 PM12/3/13
to shiny-...@googlegroups.com
Dear all,

I have a shiny app that allows the user to upload a dataset and make some ggplots. It works fine locally, but produces the following error message on the rstudio server:

Error: .onLoad failed in loadNamespace() for 'Cairo', details: call: dyn.load(file, DLLpath = DLLpath, ...) error: unable to load shared object '/home/toche/R/library/Cairo/libs/Cairo.so': libxcb-shm.so.0: failed to map segment from shared object: Cannot allocate memory

I load the following packages:

library("shiny")
library("gdata")
installXLSXsupport() # support for xlsx format
library("XLConnect") # support for xlsx format
library("reshape2")# provides function melt
library("plyr")
library("ggplot2")
library("grid") # provides function unit() for ggplot2
library("scales") # provides scale_x_y() and pretty_breaks() for ggplot2

I did install and update all the packages, by running: 

install.packages("shiny", dependencies = TRUE)

on all of them except "grid" which appears to be included in R now (?)

I also did:

install.packages("cairoDevice", dependencies = TRUE)
install.packages("Cairo.so", dependencies = TRUE)
install.packages("rJava", dependencies = TRUE)

I also read this exchange:


so I commented out: library("XLConnect") and installXLSXsupport() 

but the error persists.

Any suggestions?

Thanks!

Winston Chang

unread,
Dec 3, 2013, 9:14:32 PM12/3/13
to Patrick Toche, shiny-...@googlegroups.com
Have you tried:
install.packages('Cairo')
library(Cairo)

-Winston


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Patrick Toche

unread,
Dec 4, 2013, 12:36:09 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche

Have you tried:
install.packages('Cairo')
library(Cairo)


Thanks for your help Winston. 

I hadn't loaded the package before with library("Cairo"), assuming that since I had no need to load it locally I didn't need to load it on the server.

Now, after loading the "Cairo" library, the error message is:

The application unexpectedly exited.
Diagnostic information has been dumped to the JavaScript error console.

Here is what happens. 1. The application freezes for some time. 2. When it appears to be loaded, the conditionalPanel is open (as opposed to closed) and the area where the plots are supposed to be is black instead of the usual white. 3. When I load a dataset, the app crashes with a "memory" error message that is too quick for me to read properly. After that it hangs (dark grey colour, unresponsive).

However, I seem to have narrowed down the problem to the installXLSXsupport() function of the gdata package. I think.

I commented out as follows:

#library("gdata")
#installXLSXsupport() # support for xlsx format with gdata package

after that the app loads and works properly for a csv file. The plot area is black, rather than white, before a plot is produced, which is something I'd like to fix too. 

However, if I load an xlsx file (silly I know), I get in various places:

Error: could not find function "loadWorkbook"
Error: could not find function "getSheets"

I'm going to investigate that as soon as I can.

Thanks Winston.

Patrick Toche

unread,
Dec 4, 2013, 12:48:20 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche

However, I seem to have narrowed down the problem to the installXLSXsupport() function of the gdata package. I think.


I spoke too fast. The problem is rather with package "XLConnect". 

Here a slightly edited copy of the console output after installing the package. Perhaps you can help me "read" the error messages and take action. Thanks!

Some problem with dependency package RcppArmadillo it seems?


> install.packages("XLConnect", dependencies = TRUE)
Installing package(s) into ‘/home/toche/R/library’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
DELETED LIST OF MIRRORS HERE
Warning: dependency ‘Rcpp’ is not available
also installing the dependencies ‘RcppArmadillo’, ‘forecast’

Content type 'application/x-gzip' length 866795 bytes (846 Kb)
opened URL
==================================================
downloaded 846 Kb

Content type 'application/x-gzip' length 142778 bytes (139 Kb)
opened URL
==================================================
downloaded 139 Kb

Content type 'application/x-gzip' length 18223083 bytes (17.4 Mb)
opened URL
==================================================
downloaded 17.4 Mb

* installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/usr/local/lib/R/site-library/Rcpp/include"  -I../inst/include -fpic  -O3 -pipe  -g  -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/RcppArmadillo.h:30:0,
                 from RcppArmadillo.cpp:22:
../inst/include/RcppArmadilloForward.h:99:33: error: ‘ConstReferenceInputParameter’ is not a template
../inst/include/RcppArmadilloForward.h:100:33: error: ‘ReferenceInputParameter’ is not a template
../inst/include/RcppArmadilloForward.h:101:33: error: ‘ConstInputParameter’ is not a template
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/toche/R/library/RcppArmadillo’
* installing *source* package ‘XLConnect’ ...
** package ‘XLConnect’ successfully unpacked and MD5 sums checked
** R
** demo
** inst
** preparing package for lazy loading
Creating a generic function for ‘print’ from package ‘base’ in package ‘XLConnect’
Creating a generic function for ‘summary’ from package ‘base’ in package ‘XLConnect’
** help
*** installing help indices
** building package indices
** installing vignettes
   ‘XLConnect.Rnw’ using ‘latin1’ 
   ‘XLConnectImpatient.Rnw’ using ‘latin1’ 
** testing if installed package can be loaded

* DONE (XLConnect)
ERROR: dependency ‘RcppArmadillo’ is not available for package ‘forecast’
* removing ‘/home/toche/R/library/forecast’

The downloaded source packages are in
‘/tmp/RtmpyYpBUY/downloaded_packages’
Warning messages:
1: In install.packages("XLConnect", dependencies = TRUE) :
  installation of package ‘RcppArmadillo’ had non-zero exit status
2: In install.packages("XLConnect", dependencies = TRUE) :
  installation of package ‘forecast’ had non-zero exit status
>  

Patrick Toche

unread,
Dec 4, 2013, 12:49:50 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche
How about this?

install.packages("RcppArmadillo")
Installing package(s) into ‘/home/toche/R/library’
(as ‘lib’ is unspecified)
Error: memory exhausted (limit reached?)

Patrick Toche

unread,
Dec 4, 2013, 1:10:30 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche
could I be running out of memory?

I only have 4 very simple apps. Below is a list of packages, mostly dependencies. Any of those unnecessary and/or taking up unreasonable space? Big libraries are always listed as having 4.0K...

I deleted a few libraries that I know I'm not using and tried again. Here is the console output: It looks like a problem with RcppArmadillo, no? I tried several different repositories, just in case.

installing *source* package ‘RcppArmadillo’ ...
** package ‘RcppArmadillo’ successfully unpacked and MD5 sums checked
** libs
g++ -I/usr/share/R/include -DNDEBUG   -I"/usr/local/lib/R/site-library/Rcpp/include"  -I../inst/include -fpic  -O3 -pipe  -g  -c RcppArmadillo.cpp -o RcppArmadillo.o
In file included from ../inst/include/RcppArmadillo.h:30:0,
                 from RcppArmadillo.cpp:22:
../inst/include/RcppArmadilloForward.h:99:33: error: ‘ConstReferenceInputParameter’ is not a template
../inst/include/RcppArmadilloForward.h:100:33: error: ‘ReferenceInputParameter’ is not a template
../inst/include/RcppArmadilloForward.h:101:33: error: ‘ConstInputParameter’ is not a template
make: *** [RcppArmadillo.o] Error 1
ERROR: compilation failed for package ‘RcppArmadillo’
* removing ‘/home/toche/R/library/RcppArmadillo’

The downloaded source packages are in
‘/tmp/Rtmpy79MpU/downloaded_packages’
Warning message:
In install.packages("RcppArmadillo", dependencies = TRUE) :
  installation of package ‘RcppArmadillo’ had non-zero exit status


toche@spark:~/R/library$ ls -lah
total 88K
drwxrwxr-x 73 toche toche 4.0K Dec  4 05:40 .
drwxrwxr-x  3 toche toche   20 Nov 11 14:06 ..
drwxr-xr-x  6 toche toche   93 Dec  3 22:28 abind
drwxr-xr-x  7 toche toche  104 Dec  3 21:20 bitops
drwxr-xr-x  6 toche toche 4.0K Nov 11 14:09 brew
drwxr-xr-x  7 toche toche  115 Dec  3 22:53 Cairo
drwxr-xr-x  7 toche toche  104 Dec  3 22:39 caTools
drwxr-xr-x  9 toche toche  139 Dec  3 21:21 cluster
drwxr-xr-x  6 toche toche   93 Dec  3 21:21 codetools
drwxr-xr-x  9 toche toche 4.0K Nov 11 14:12 colorspace
drwxr-xr-x  8 toche toche  120 Dec  3 22:33 devtools
drwxr-xr-x  7 toche toche  104 Nov 11 14:12 dichromat
drwxr-xr-x  7 toche toche  116 Dec  3 21:20 digest
drwxr-xr-x 10 toche toche  156 Dec  3 22:29 doMC
drwxr-xr-x  7 toche toche  116 Nov 11 14:07 evaluate
drwxr-xr-x  8 toche toche  149 Dec  3 22:31 fImport
drwxr-xr-x 10 toche toche  156 Dec  3 22:29 foreach
drwxr-xr-x  8 toche toche  127 Nov 11 14:09 formatR
drwxr-xr-x  7 toche toche  129 Nov 11 14:13 Formula
drwxr-xr-x  7 toche toche  104 Dec  3 22:30 fracdiff
drwxr-xr-x 12 toche toche 4.0K Dec  3 22:55 gdata
drwxr-xr-x 10 toche toche 4.0K Dec  3 22:54 ggplot2
drwxr-xr-x  7 toche toche  116 Nov 11 14:13 gtable
drwxr-xr-x  8 toche toche  142 Dec  3 21:44 gtools
drwxr-xr-x  9 toche toche  125 Nov 11 14:13 hexbin
drwxr-xr-x  7 toche toche  114 Nov 11 14:09 highr
drwxr-xr-x  7 toche toche 4.0K Dec  3 21:19 Hmisc
drwxr-xr-x  8 toche toche  140 Nov 11 14:07 httpuv
drwxr-xr-x  8 toche toche  127 Nov 11 14:09 httr
drwxr-xr-x  9 toche toche  134 Dec  3 22:28 iterators
drwxr-xr-x  7 toche toche  119 Dec  3 22:29 itertools
drwxr-xr-x 14 toche toche 4.0K Nov 11 14:09 knitr
drwxr-xr-x  6 toche toche   93 Nov 11 14:13 labeling
drwxr-xr-x 10 toche toche 4.0K Dec  3 21:21 lattice
drwxr-xr-x  7 toche toche  118 Nov 11 14:14 mapproj
drwxr-xr-x  9 toche toche  129 Nov 11 14:13 maps
drwxr-xr-x 12 toche toche 4.0K Nov 11 14:14 maptools
drwxr-xr-x 11 toche toche 4.0K Nov 11 14:07 markdown
drwxr-xr-x 12 toche toche 4.0K Dec  3 21:24 Matrix
drwxr-xr-x  6 toche toche   93 Nov 11 14:09 memoise
drwxr-xr-x  8 toche toche  130 Dec  3 21:25 mgcv
drwxr-xr-x 11 toche toche 4.0K Nov 11 14:14 multcomp
drwxr-xr-x  7 toche toche  128 Nov 11 14:13 munsell
drwxr-xr-x  8 toche toche  140 Nov 11 14:13 mvtnorm
drwxr-xr-x  8 toche toche  139 Dec  3 21:21 nnet
drwxr-xr-x  9 toche toche  153 Dec  3 22:56 plyr
drwxr-xr-x  8 toche toche  125 Dec  3 22:31 png
drwxr-xr-x  8 toche toche 4.0K Nov 11 14:13 proto
drwxr-xr-x  7 toche toche  104 Dec  3 22:30 quadprog
drwxr-xr-x 10 toche toche 4.0K Nov 11 14:13 quantreg
drwxr-xr-x  6 toche toche  107 Nov 11 14:12 RColorBrewer
drwxr-xr-x 13 toche toche 4.0K Dec  3 22:34 RCurl
drwxr-xr-x  8 toche toche  142 Dec  3 22:56 reshape2
drwxr-xr-x  8 toche toche  126 Nov 11 14:09 roxygen2
drwxr-xr-x 10 toche toche  148 Dec  3 21:21 rpart
drwxr-xr-x 10 toche toche 4.0K Dec  3 22:30 RUnit
drwxr-xr-x  8 toche toche  140 Nov 11 14:13 sandwich
drwxr-xr-x  7 toche toche  116 Dec  3 22:57 scales
drwxr-xr-x 10 toche toche 4.0K Dec  3 22:29 shiny
drwxr-xr-x  9 toche toche  151 Nov 11 14:12 shinyIncubator
drwxr-xr-x 12 toche toche 4.0K Nov 11 14:13 sp
drwxr-xr-x 11 toche toche 4.0K Nov 11 14:13 SparseM
drwxr-xr-x  7 toche toche  116 Nov 11 14:06 stringr
drwxr-xr-x  9 toche toche  154 Dec  3 21:21 survival
drwxr-xr-x  7 toche toche  116 Nov 11 14:07 testthat
drwxr-xr-x  7 toche toche  106 Nov 11 14:13 TH.data
drwxr-xr-x  7 toche toche  130 Dec  3 22:30 timeDate
drwxr-xr-x  8 toche toche 4.0K Dec  3 22:31 timeSeries
drwxr-xr-x  8 toche toche  130 Dec  3 22:31 tseries
drwxr-xr-x  8 toche toche  128 Nov 11 14:09 whisker
drwxr-xr-x 11 toche toche 4.0K Dec  4 05:40 XLConnect
drwxr-xr-x 10 toche toche  151 Dec  3 22:34 XML
drwxr-xr-x  9 toche toche  151 Nov 11 14:12 zoo
toche@spark:~/R/library$ 

Patrick Toche

unread,
Dec 4, 2013, 1:37:21 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche
I copied the whole RcppArmadillo directory from my laptop to the remote library directory:

$ scp -r /tmp/RcppArmadillo to...@spark.rstudio.com:R/library/

Not helping however...

RcppArmadillo is in the library directory now:

toche@spark:~/R/library$ ls
abind       evaluate  Hmisc      memoise       RcppArmadillo   stringr
bitops      fImport   httpuv     mgcv          RCurl           survival
brew        foreach   httr       multcomp      reshape2        testthat
Cairo       formatR   iterators  munsell       roxygen2        TH.data
caTools     Formula   itertools  mvtnorm       rpart           timeDate
cluster     fracdiff  labeling   nnet          RUnit           timeSeries
codetools   gdata     lattice    plyr          sandwich        tseries
colorspace  ggplot2   mapproj    png           scales          whisker
devtools    gtable    maps       proto         shiny           XLConnect
dichromat   gtools    maptools   quadprog      shinyIncubator  XML
digest      hexbin    markdown   quantreg      sp              zoo
doMC        highr     Matrix     RColorBrewer  SparseM
toche@spark:~/R/library$ 

Patrick Toche

unread,
Dec 4, 2013, 1:44:05 AM12/4/13
to shiny-...@googlegroups.com, Patrick Toche
Just wondering about this: when I log in to spark.rstudio.com, it tells me that:

1) memory usage is 52% (or maybe 9.9%) so there should be no memory problem

2) there are 2 zombie processes: doesn't sound good. Should I do something about these zombies?

3) there's a whole bunch of packages that need updating. Is there a command I have to run to update these?

Sorry, total newbie. Thanks!


Welcome to Ubuntu 12.04.2 LTS (GNU/Linux 3.2.0-45-virtual x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Wed Dec  4 06:30:18 UTC 2013

  System load:    3.72                Processes:           414
  Usage of /home: 9.9% of 1023.50GB   Users logged in:     2
  Memory usage:   52%                 IP address for eth0: 10.253.29.69
  Swap usage:     0%

  => There are 2 zombie processes.

  Graph this data and manage this system at https://landscape.canonical.com/

214 packages can be updated.
116 updates are security updates.

Winston Chang

unread,
Dec 4, 2013, 1:22:35 PM12/4/13
to Patrick Toche, shiny-...@googlegroups.com
Hi Patrick -

I think you may be running into issues related to the slightly older version of R (2.15.2) that we have installed on Glimmer and Spark. Unfortunately, upgrading R on those servers has the potential to break everyone's Shiny apps.

We've been putting our efforts into setting up a new hosting service, which will let you use the latest version of R. You can sign up for the alpha here, and we'll get you set up right away: http://shinyapps.io

-Winston



Patrick Toche

unread,
Dec 4, 2013, 8:07:43 PM12/4/13
to shiny-...@googlegroups.com, Patrick Toche
Thanks Winston, just did!

Patrick Toche

unread,
Dec 8, 2013, 12:15:58 PM12/8/13
to shiny-...@googlegroups.com, Patrick Toche

It looks like the problem persists. Something related to rJava. Any suggestions? Thanks!

> deployApp()
Preparing to deploy application...DONE
Uploading application bundle...DONE
Deploying application...
Waiting for task: 15219
  building: Building 25 packages
  building: Building package xtable-1.7-1
  building: Building package labeling-0.2
  building: Building package Cairo-1.5-2
Error: Unhandled Exception: Child Task 15220 error: Unhandled Exception: Child Task 15223 failed: Error building package: Error building Cairo (1.5-2). Image build exited with non-zero status: 1

> deployApp()
...
Deploying application...
Waiting for task: 15224
  building: Building 22 packages
  building: Building package stringr-0.6.2
  building: Building package plyr-1.8
  building: Building package RColorBrewer-1.0-5
  building: Building package proto-0.3-10
  building: Building package dichromat-2.0-0
  building: Building package bitops-1.0-6
  building: Building package caTools-1.16
  building: Building package digest-0.6.3
  building: Building package gtable-0.1.2
  building: Building package lattice-0.20-24
  building: Building package reshape2-1.2.2
  building: Building package MASS-7.3-29
  building: Building package colorspace-1.2-4
  building: Building package munsell-0.4.2
  building: Building package scales-0.2.3
  building: Building package RJSONIO-1.0-3
  building: Building package ggplot2-0.9.3.1
  building: Building package Rcpp-0.10.5
  building: Building package httpuv-1.2.0
  building: Building package rJava-0.9-4
Error: Unhandled Exception: Child Task 15225 error: Unhandled Exception: Child Task 15245 failed: Error building package: Error building rJava (0.9-4). Image build exited with non-zero status: 1


Winston Chang

unread,
Dec 8, 2013, 3:03:20 PM12/8/13
to Patrick Toche, shiny-...@googlegroups.com
Hi Andy -

One of our ShinyApps users is having trouble with rJava. We've encountered this on glimmer and spark in the past. The workaround was to run the following:
    _JAVA_OPTIONS=-Xmx256m R CMD javareconf

... although I believe we had a configuration change along the way which prevents this from working now. The r::rjava recipe in the deploy-test repo has comments with a little more information about it.

-Winston


Winston Chang

unread,
Dec 8, 2013, 3:06:46 PM12/8/13
to Patrick Toche, shiny-...@googlegroups.com
Hi Patrick - I forwarded your message to Andy Kipp <an...@rstudio.com>, who will be able to look into the issue with ShinyApps. (I also accidentally sent an extra copy of the message to this list.)

-Winston

Patrick Toche

unread,
Dec 9, 2013, 1:50:18 AM12/9/13
to shiny-...@googlegroups.com, Patrick Toche
Thanks Winston!

Below is the version of rJava I have on my laptop, where I'm not experiencing any problems.

Package: rJava
Version: 0.9-4
Title: Low-level R to Java interface
Author: Simon Urbanek <simon....@r-project.org>
Maintainer: Simon Urbanek <simon....@r-project.org>
Depends: R (>= 2.5.0), methods
Description: Low-level interface to Java VM very much like .C/.Call and
        friends. Allows creation of objects, calling methods and
        accessing fields.
License: GPL-2
SystemRequirements: java
Packaged: 2013-03-11 16:02:23 UTC; svnuser
NeedsCompilation: yes
Repository: CRAN
Date/Publication: 2013-03-12 10:54:30
Built: R 3.0.0; x86_64-apple-darwin10.8.0; 2013-04-03 15:15:11 UTC; unix
Archs: rJava.so.dSYM

Patrick Toche

unread,
Dec 9, 2013, 2:16:43 AM12/9/13
to shiny-...@googlegroups.com, Patrick Toche
I copied the rJava folder I have in my R library in my laptop to the server, but here's the message I get now when I try to load the app:

Loading required package: rJava Warning: package ‘rJava’ was built under R version 3.0.0 Error: package ‘rJava’ was built for x86_64-apple-darwin10.8.0 Execution halted

I don't get this message on my laptop.

Patrick Toche

unread,
Dec 17, 2013, 3:26:31 AM12/17/13
to shiny-...@googlegroups.com, Patrick Toche
The bottom line is that rJava is not currently supported, so that pretty much rules out using the Java-based "XLConnect" library I was using to load and read xlsx files. One workaround is to use the Perl-based "gdata" library. 

I had to alter the code a little, to replace functions provided by the XLConnect library. For instance:
#      , 'choices' = getSheets(loadWorkbook(input$dataset$datapath))# package "XLConnect"
      , 'choices' = sheetNames(input$dataset$datapath)# package "gdata"

Another approach is to use the xlsxToR function written by Schaun Wheeler or the version modified by Zheng that is supposed to be more efficient. References:

Thanks to all for your feedback. My app now runs smoothly on the server.  :-)

Shreeram Iyer

unread,
Feb 19, 2016, 1:54:01 AM2/19/16
to Shiny - Web Framework for R
Error in library.dynam(lib, package, package.lib) : shared object ‘digest.so’ not found Error: package or namespace load failed for ‘shiny’ Execution halted
Reply all
Reply to author
Forward
0 new messages