0

This is a very specific question.

I have a simple Shiny app, using the latest version of R (3.2.2), RStudio (0.99.473), all packages up-to-date, tested in both Windows 7 and Ubuntu 14.04. The same thing happens in both SOs.

I have a library of functions which I embedded in a "package", with a properly created DESCRIPTION file. I use devtools to load this package. So, the first lines of code in my very simple Shiny app are

library("devtools")
load_all("../../RTEMP");

Since I plan to use some of these functions within the Shiny app. The package name is not actually RTEMP, I created this temporarily in order to isolate the problem. This temporary package has one single file inside RTEMP/R/, something.r. This file contains one line of code:

AA <- setRefClass("AA");

So I am creating a reference class with nothing but a name (my original code relies on R objects of this type). I am not doing anything with the package, simply loading it.

When running the Shiny app for the first time after opening RStudio, it works fine. If I close the app and open it again, I get the following error message:

ERROR: shinyjs: you cannot mix named and unnamed arguments in the same function call

Curiously, if I change the beginning of my Shiny app to this:

#library("devtools")
#load_all("../../RTEMP");
AA <- setRefClass("AA");

So, commenting the package loading and setting the reference class inside the Shiny app, everything works fine.

The problem happens when I call setRefClass from within a package loaded with devtools, but not when I call it directly from Shiny. Also, I can load it the first time, but not the second (the Shiny Window simply shows the error message above).

Any ideas what may be causing this bug?

Thank you very much.

DeanAttali
  • 25,268
  • 10
  • 92
  • 118
Chicoscience
  • 975
  • 1
  • 8
  • 18
  • I think the problem has to do more with devtools than Shiny. When executing load_all, the function by default tries to unload the package and load it again. The documentation for the unload function mentions some bugs with S4 classes, that they are not unloaded properly. I wonder if refClasses may experience the same problem. It seems to me that the 2nd time I load the package, the residual from the 1st time I loaded may be causing this bug. – Chicoscience Aug 19 '15 at 22:48
  • Looking at the error message, it looks like it's trying to call a `shinyjs` function. This can happen if shinyjs is loaded and you have a non-namespaced function call to a function that shinyjs has. For example, shinyjs has a function `info`, so if you're using a package that makes a call to `info` it might be accidentally reaching the shinyjs version. I just updated the shinyjs github version to also include the function that was called in the error message, so you can try downloading the newest version (`devtools::install_github("daattali/shinyjs")`) and see what function causes that error – DeanAttali Aug 20 '15 at 05:50
  • Thanks, @daattali. With your update, I found out that the cause for the problem is the function `removeClass` - So I believe that the problem is caused when `devtools` calls its `unload` function before loading the package for the second time. – Chicoscience Aug 20 '15 at 17:03
  • Since I believe this to be actually a bug in `devtools`, I reported a bug there, here is the [link](https://github.com/hadley/devtools/issues/899). – Chicoscience Aug 20 '15 at 17:12
  • If it's the removeClass method, my guess is that somehwere there is a call to `removeClass` that should be `methods::removeClass` instead – DeanAttali Aug 20 '15 at 18:43
  • I believe you are right, @daattali, indeed I suggested this in the third comment of this devtools [bug report](https://github.com/hadley/devtools/issues/899) – Chicoscience Aug 20 '15 at 20:21

1 Answers1

1

It is actually a problem in the devtools package that is causing incompatibility with shinyjs. I submited this bug report and hopefully this will not happen in the next versions.

If you experienced a similar error message with Shiny, there might be other functions in other packages (or in your own package) that needs the namespace.

Chicoscience
  • 975
  • 1
  • 8
  • 18
  • 1
    This is a problem that happens in a lot of packages, and since June 29th 2015 it's acutally being checked. So any package that was submitted to CRAN after June 29 will not have this problem because they are now strict about namespacing. – DeanAttali Aug 21 '15 at 00:59