Application depends on package "rlang" but it is not installed - r

I am trying to publish shiny app. It keeps giving me this output:
Preparing to deploy application...DONE
Uploading bundle for application: 5894015...Warning:
* May be unable to deploy package dependency 'AnnotationDbi'; could
not determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'AnnotationFilter'; could
not determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'AnnotationHub'; could
not determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'Biobase'; could not
determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'BiocFileCache'; could
not determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'BiocGenerics'; could not
determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'BiocIO'; could not
determine a repository URL for the source 'Bioconductor'.
* May be unable to deploy package dependency 'BiocParallel'; could not
[... truncated]
Error:
* Application depends on package "rlang" but it is not installed.
Please resolve before continuing.
Execution halted
rlang is installed and I did library(rlang) but that didn't help. rlang version is 1.0.2, is it a version issue? everything is working fine, but it's not deploying for some reason.
The packages I am loading at the start of the shiny app are:
library(rlang)
library(data.table)
library(dplyr)
library(shiny)
library(shinythemes)
library(compGenomRData)
library(BiocManager)
library(DESeq2)
library(org.Hs.eg.db)
library(TxDb.Hsapiens.UCSC.hg19.knownGene)
library(EnsDb.Hsapiens.v86)
library(AnnotationHub)
library(AnnotationDbi)
library(pheatmap)
library(EnhancedVolcano)
library(ggplot2)
library(devtools)
library(clusterProfiler)
library(enrichplot)
library(msigdbr)
library(readxl)
library(annotate)
I need all of them for my server function.
what is the problem here ?
EDIT-
I tried uninstallng rlang library with remove.packages('rlang'), gave me this output:
Error in remove.packages : there is no package called 'rlang'
How is this even possible ?

Related

How to Deploy Local Package to Shinyapps.io

I am trying to deploy an app to Shiny.io with a new package via rsconnect::deployApp() that I have developed locally and not hosted on CRAN. My question is similar to this one but I cannot solve using the same recommendation.
My package is installed on a private github repository and my shinyapps.io account settings have access to this private repo. My app depends on packages both on CRAN and now also this new one I have developed.
Could use a bit of direction on how to solve this.
Thanks
Uploading bundle for application: 5447651...Warning:
* May be unable to deploy package dependency 'Mycpp'; could not determine a repository URL for the source 'CRAN'.
* Unable to determine the source location for some packages. Packages should be installed from a package repository like CRAN
or a version control system. Check that options('repos') refers to a package repository containing the needed package
versions.
DONE
Deploying bundle: 6849209 for application: 5447651 ...
Waiting for task: 1273530594
building: Processing bundle: 6849209
building: Parsing manifest
building: Building image: 8100493
building: Fetching packages
building: Building package: Mycpp
################################ Begin Task Log ################################
################################# End Task Log #################################
Error: Unhandled Exception: Child Task 1273530595 failed: Error building image: Error fetching Mycpp (1.0) source. <CRANPackageSource repo='http://cran.rstudio.org'> unable to satisfy package: Mycpp (1.0)
In addition: Warning message:
In FUN(X[[i]], ...) :
Package 'Mycpp 1.0' was installed from sources; Packrat will assume this package is available from a CRAN-like repository during future restores

deployment on shinyapps.io failing

Hi I'm trying to deploy an app on the server, however, I get the following errors
* May be unable to deploy package dependency "rClr" could not
determine a repository URL for the source CRAN.
* May be unable to deploy package dependency "tlf" could not determine
a repository URL for the source CRAN.
Unable to determine the source location for some packages. Packages
should be installed from a package repository like CRAN or a version
control system. Check that options(repos) refers to a package
repository containing the needed package versions.
The backbone packages can not be installed from Cran and have to be done manually, hence the errors. How can this be fixed in order to deploy the app on the server?
Thanks for all help

Install R package from GitHub in package vignette

I've built an R package and it's available on CRAN. I am updating one of the vignettes and I would like to install a package from GitHub in the vignette. The R CMD Checks ran smoothly on my machine, but after submission to CRAN I received a message indicating that I need to install the package to a temporary library.
I used this code to attempt to install the package to a temporary directory. The code works on my local machine and the R CMD Checks pass locally (devtools::check() and devtools::check(remote = TRUE)). But the checks fail when run on the CRAN machine (rhub::check_for_cran()).
# adding temp_path to .libPaths
temp_path <- file.path(tempdir(), "gt_folder"); dir.create(temp_path)
lib_path <-.libPaths()
.libPaths(c(lib_path, temp_path))
remotes::install_github("rstudio/gt", lib = temp_path)
gt::gt(mtcars)
This is the error I see from rhub::check_for_cran(). It seems the dependencies are not being handled correctly.
ERROR: dependencies 'lazyeval', 'reshape2', 'scales', 'tibble' are not available for package 'ggplot2'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/ggplot2'
ERROR: dependencies 'fansi', 'utf8', 'vctrs' are not available for package 'pillar'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/pillar'
The downloaded source packages are in
'C:\Users\USERVzKWFkopnQ\AppData\Local\Temp\RtmpIjoZQH\working_dir\RtmpiwGvJu\downloaded_packages'
ERROR: dependencies 'checkmate', 'commonmark', 'dplyr', 'fs', 'ggplot2', 'sass', 'scales', 'tibble', 'tidyselect' are not available for package 'gt'
- removing 'C:/Users/USERVzKWFkopnQ/AppData/Local/Temp/RtmpIjoZQH/working_dir/RtmpiwGvJu/gt_folder/gt'
Quitting from lines 18-45 (install_from_github.Rmd)
Error: processing vignette 'install_from_github.Rmd' failed with diagnostics:
there is no package called 'gt'
--- failed re-building 'install_from_github.Rmd'
SUMMARY: processing the following file failed:
'install_from_github.Rmd'
Error: Vignette re-building failed.
Execution halted
Here's a light-weight package with only one function and a vignette illustrating the problem https://github.com/ddsjoberg/pkginstallgh
Here is the note I received from CRAN
Dear maintainer,
Pls see
<https://cran.r-project.org/web/checks/check_results_gtsummary.html>.
The check problems on the Debian systems are caused by attempts to write
to the user library to which all packages get installed before checking
(and which now is remounted read-only for checking).
Having package code which is run as part of the checks and attempts to
write to the user library violates the CRAN Policy's
Packages should not write in the user’s home filespace (including
clipboards), nor anywhere else on the file system apart from the R
session’s temporary directory (or during installation in the location
pointed to by TMPDIR: and such usage should be cleaned up).
In your case, you need to teach remotes::install_github("rstudio/gt") to
install to a temporary library and use it from there.

Error in deployment to shinyapps.io

The following is the error i received:
Loading required package: tmap
Warning in library(package, lib.loc = lib.loc, character.only = TRUE, logical.return = TRUE, :
there is no package called ‘tmap’
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Warning in install.packages(p) :
'lib = "/usr/local/lib/R/site-library"' is not writable
Error in value[[3L]](cond) : unable to install packages
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
The following is my code:
packages = c('tmap', 'sf', 'tidyverse', 'RColorBrewer', 'classInt',
'raster', 'sp', 'REAT', 'SpatialAcc', 'shiny', 'leaflet', 'factoextra',
'NbClust')
for(p in packages){
if(!require(p, character.only = T)){
install.packages(p)
}
library(p, character.only = T)
}
What could be the problem?.
I tried deploying through the following command in rstudio.
library(rsconnect)
rsconnect::deployApp('D:/student/mypath')
The issue is that shinyapps.io doesn't let you install R packages on their server. Allowing that would not really make sense for security reasons so please don't try to "hack" your way into an installation.
Instead file an issue (or a PR) on the github repo shinyapps dependencies and ask them to support your missing packages.
A second solution is to purchase a server and set up shiny-server yourself. Then you will be free to install packages at will. Instructions about that can be found here.
Edit: Actually, it seems custom libraries are supported on shinyapps.io and they will be installed automatically based on your library and require calls. So you probably just need to remove the ìnstall.packages part in your uploaded app.
When you deploy your application, the rsconnect package attempts to detect the packages that your application uses. rsconnect sends this list of packages and their dependencies along with your application to the shinyapps.io service. Then shinyapps.io builds and installs the packages into the R library for your application. The first time you deploy your application, it may take some time to build these packages (depending on how many packages are used). However, you will not wait for these packages to build during future deployments (unless you upgrade or downgrade a package)
-- Shinyapps.io - Getting started

Loading dependencies from package-internal packrat library

I am building an R package with packrat. The package is fully tested and installation from the locally saved source file by
install.packages("myPackage.tar.gz", repos = NULL, type = "source")
works if all dependencies (specified in the Imports: field) are installed on the local machine.
However, I would like to install that package on another server where dependencies are not installed. When I try to do this, I get the error
"ERROR: dependencies ‘survey’, ‘dplyr’ are not available for package 'myPackage'"
I also tried to install the packrat bundle which I created by calling
packrat::bundle(project = 'pathtomypackageproject', file = 'myPackage.tar.gz',
include.lib = TRUE)
but I get the same error.
I think the problem is that, upon installing 'myPackage', R searches the first element of .libPaths(), doesn't find anything and since "repos = NULL" is specified, has nowhere to install the packages from so the error is thrown.
A solution I'm still trying to avoid is to transfer a repository containing all dependencies to the server and pointing to the repository when installing the package. Ideally, I only have to transfer myPackage.tar.gz.
My question is if there is some way to point to the internal packrat library, where all dependencies can be found, and import the namespaces from there.
If you have included the list of packages to be imported in DESCRIPTION File, then you just need to do this while installation of your package:
install.packages("myPackage",dependencies=TRUE)

Resources