Search code examples
ropencpu

Error starting OpenCPU in rstudio OnAttach failed


I am trying to get a simple OpenCPU Apps (from https://www.opencpu.org/download.html).

Since I am on Ubuntu on AWS, I follow the instructions for Ubuntu:

# Requires Ubuntu 14.04 (Trusty) or 16.04 (Xenial)
sudo add-apt-repository -y ppa:opencpu/opencpu-1.6
sudo apt-get update 
sudo apt-get upgrade

# Installs OpenCPU server
sudo apt-get install -y opencpu
# Done! Open http://yourhost/ocpu in your browser

# Optional: installs rstudio in http://yourhost/rstudio
sudo apt-get install -y rstudio-server 

Goes through all right.

Next I try to install the package in Rstudio:

install.packages("opencpu")
Installing package into ‘/home/ruser/R/x86_64-pc-linux-gnu-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/src/contrib/opencpu_1.6.1.tar.gz'
Content type 'unknown' length 563159 bytes (549 KB)
==================================================
downloaded 549 KB

* installing *source* package ‘opencpu’ ...
** package ‘opencpu’ successfully unpacked and MD5 sums checked
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (opencpu)

The downloaded source packages are in
    ‘/tmp/RtmpON3Ujv/downloaded_packages’
> library(opencpu)
Initiating OpenCPU server...
Using config: /home/ruser/.opencpu.conf
OpenCPU started.
[httpuv] http://myserver/rstudio/p/1529/ocpu
Error : .onAttach failed in attachNamespace() for 'opencpu', details:
  call: rhttpd$init()
  error: could not find function "startDynamicHelp"
Error: package or namespace load failed for ‘opencpu’

This is where I get the error. Tried googling the error but no luck.


Solution

  • @gaurav is correct. The instructions on opencpu are very misleading, because it looks like they're showing a single set of instructions, but in fact, the R commands are for running opencpu in an interactive R session, not with your newly installed opencpu cloud server.

    To run the sample apps on your new cloud server (which is what I assume you are trying to do), you need to follow the instructions for the cloud server.

    Here's the link to the cloud server docs that helped me:

    https://cran.r-project.org/web/packages/opencpu/vignettes/opencpu-server.pdf

    Specifically, to run the sample apps, you'll need to start an R session as root, and install the packages:

    sudo -i
    R
    
    #then from r session
    library(devtools)
    install_github("opencpu/gitstats")
    install_github("opencpu/stocks")
    
    #then quit
    quit()
    
    exit
    

    then restart the opencpu service:

    sudo service opencpu restart
    

    then, you can navigate to the package using the opencpu api. In a web browser, go to:

    http://localhost/ocpu/library/gitstats/www/

    and voila-