rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
131 stars 80 forks source link

Bug: error if requireNamespace is used in function #423

Closed lz100 closed 4 years ago

lz100 commented 4 years ago

I have a function which contains following code:

missing_pkgs <- lapply(packages, function(pkg) {
        if (!requireNamespace(pkg, quietly = TRUE)) pkg
}

reconnect treat variable pkg as a package. The intend of this function is to check if my environment has some packages but installation is not requried. This is to help users when they lunch the app locally. I will not install packages for them, just checking. reconnect thinks I need to install these packages, and it treats the variable pkg as a package name too.

Preparing to deploy application...DONE
Uploading bundle for application: 2205958...Error: Unable to retrieve package records for the following packages:
- 'pkg'
In addition: Warning message:
In FUN(X[[i]], ...) : Package 'pkg' not available in repository or locally
Execution halted

If I don't include this line, deployment was successful.

For now, I have to use hack like eval(parse(text = "requireNamespace(pkg, quietly = TRUE)")). I would appreciate if you could fix this bug.

jmcphers commented 4 years ago

The rsconnect package itself does not detect these dependencies; Packrat does that. If this is still a problem for you, I'd suggest creating a tiny Packrat project that demonstrates the issue and submitting it to that repo:

https://github.com/rstudio/packrat