Shiny-server does not show rmarkdown even in the example page (rmarkdown package installed) - r

I installed a shiny-server on Amazon AWS EC-2 (Amazon Linux AMI 2015.09.1 (HVM), SSD Volume Type - ami-60b6c60a). The server works fine for the Shiny apps, but does not render the .rmd, even the rmd from the example page.
I only see this error:
Error: error in running command
In the HTML:
<div id="__reactivedoc__" class="shiny-html-output shiny-bound-output shiny-output-error">error in running command</div>
I already installed the rmarkdown package, it works fine on Rstudio. (I use the same user for Rstudio and Shiny server).
I don't know how to get more information about the error, I don't see other messages.
Somebody have an idea?
NEW INFO:
I investigate the logs from the server:
This is the output from the /var/log/shiny-server/:
su: ignore --preserve-environment, it's mutually exclusive to --login.
Listening on http://127.0.0.1:52294
/opt/shiny-server/ext/pandoc/pandoc: error while loading shared libraries: libgmp.so.3: cannot open shared object file: No such file or directory
Warning: Error in system: error in running command
Stack trace (innermost first):
97: system
96: force
95: with_pandoc_safe_environment
94: get_pandoc_version
93: FUN
92: lapply
91: find_pandoc
90: pandoc_available
89: <Anonymous>
88: do.call
87: contextFunc
86: .getReactiveEnvironment()$runWith
85: shiny::maskReactiveContext
84: reactive reactive({
out <- rmd_cached_output(file, encoding)
output_dest <- out$dest
if (out$cached) {
if (nchar(out$resource_folder) > 0) {
shiny::addResourcePath(basename(out$resource_folder),
out$resource_folder)
}
return(out$shiny_html)
}
if (!file.exists(dirname(output_dest))) {
dir.create(dirname(output_dest), recursive = TRUE, mode = "0700")
}
resource_folder <- knitr_files_dir(output_dest)
perf_timer_reset_all()
dependencies <- list()
shiny_dependency_resolver <- function(deps) {
dependencies <<- deps
list()
}
output_opts <- list(self_contained = FALSE, copy_resources = TRUE,
dependency_resolver = shiny_dependency_resolver)
message("\f")
args <- merge_lists(list(input = reactive_file(), output_file = output_dest,
output_dir = dirname(output_dest), output_options = output_opts,
intermediates_dir = dirname(output_dest), runtime = "shiny"),
render_args)
result_path <- shiny::maskReactiveContext(do.call(render,
args))
if (!dir_exists(resource_folder))
dir.create(resource_folder, recursive = TRUE)
shiny::addResourcePath(basename(resource_folder), resource_folder)
dependencies <- append(dependencies, list(create_performance_dependency(resource_folder)))
write_deps <- base::file(file.path(resource_folder, "shiny.dep"),
open = "wb")
on.exit(close(write_deps), add = TRUE)
serialize(dependencies, write_deps, ascii = FALSE)
if (!isTRUE(out$cacheable)) {
shiny::onReactiveDomainEnded(shiny::getDefaultReactiveDomain(),
function() {
unlink(result_path)
unlink(resource_folder, recursive = TRUE)
})
}
shinyHTML_with_deps(result_path, dependencies)
})
73: doc
72: shiny::renderUI
71: func
70: output$__reactivedoc__
3: <Anonymous>
2: do.call
1: rmarkdown::run
On the /opt/shiny-server/ext/pandoc/ I have these:
-rwxrwxr-x 1 root root 37191008 Feb 3 2014 pandoc
-rwxrwxr-x 1 root root 38520576 Feb 3 2014 pandoc-citeproc
drwxrwxr-x 2 root root 4096 Jan 13 15:15 static
I tried to install "gmp.x86_64", but the results are:
> yum install gmp.x86_64
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
epel/x86_64/metalink | 3.0 kB 00:00
epel/x86_64 | 4.3 kB 00:00 ...
epel/x86_64/updateinfo | 715 kB 00:00
epel/x86_64/primary_db | 5.8 MB 00:01
949 packages excluded due to repository priority protections
Package gmp-6.0.0-11.16.amzn1.x86_64 already installed and latest version
Nothing to do
And still not working.... Maybe there is another package?
In my "/usr/lib64/" I have libgmp.so.10.2.0, but I think I don't have libgmp.so.3.
Even installing the i686 version, still the same.

For Fedora 23 I had the same problem
[root#pjux shiny-server]# ldd -d /opt/shiny-server/ext/pandoc/pandoc
linux-vdso.so.1 (0x00007ffff9eb0000)
libz.so.1 => /lib64/libz.so.1 (0x00007fc20bd55000)
librt.so.1 => /lib64/librt.so.1 (0x00007fc20bb4d000)
libutil.so.1 => /lib64/libutil.so.1 (0x00007fc20b949000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fc20b745000)
libgmp.so.3 => not found
libffi.so.5 => not found
libm.so.6 => /lib64/libm.so.6 (0x00007fc20b442000)
libc.so.6 => /lib64/libc.so.6 (0x00007fc20b081000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fc20ae63000)
/lib64/ld-linux-x86-64.so.2 (0x0000561bb7c14000)
but
ln -s /lib64/libffi.so.6.0.2 /lib64/libffi.so.5
ln -s /lib64/libgmp.so.10.2.0 /lib64/libgmp.so.3
solved it

I solved the problem with help from the github issues page of shiny-server
How sjpascual said, just install the packages: compat-gmp4 and compat-libffi5 to fix it.
Now is working fine.

This is an old post but in case someone has a similar problem. You may try to install the RMarkdown package from console as root instead of inside RStudio to make the package available to the Shiny server:
sudo su - -c "R -e \"install.packages('rmarkdown', repos='http://cran.rstudio.com/')\""
That helped me to get the RMarkdown sample app in the test page to load...

For CentOS 7, installing gmp-devel and libffi-devel and restarting Shiny Server resolved the issue.

Related

Error when deploying shiny app with reticulate, python and keras

I am trying to deploy shiny app, that uses reticulate and keras packages. I do not have any problem to run it locally, but real troubles appear, when I try to deploy it to shinyapps.io. My app.r file is as follows:
virtualenv_dir = Sys.getenv("VIRTUALENV_NAME")
python_path = Sys.getenv("PYTHON_PATH")
reticulate::virtualenv_create(envname = virtualenv_dir, python = python_path)
reticulate::virtualenv_install(virtualenv_dir, packages = c("numpy", "h5py", "scipy", "scikit-image", "pyyaml", "pillow"), ignore_installed = TRUE)
reticulate::use_virtualenv(virtualenv = virtualenv_dir)
library(shiny)
library(keras)
library(reticulate)
library(magick)
library(raster)
library(EBImage)
library(rdrop2)
library(plotly)
np <- import("numpy", convert=FALSE)
ndi <- import("scipy.ndimage", convert=FALSE)
segment <- import("skimage.segmentation", convert=FALSE)
feature <- import("skimage.feature", convert=FALSE)
model = load_model_hdf5("model_v02122020.h5")
ui <-
tagList(
fluidPage(
sidebarLayout(sidebarPanel(
fileInput("upload", "Choose a file", accept = c('image/png', 'image/jpeg')),
actionButton('click', 'Start')
),
mainPanel(
tabsetPanel(type="tabs",
tabPanel("Input image", plotOutput("InputImagePlot", height="100%")),
tabPanel("Output image", plotOutput("OutputImagePlot", height="100%")),
)
)
)
)
)
server <-
function(input, output, session) {
observeEvent(input$click, {
## some code for image processing
})
}
shinyApp(ui = ui, server = server)
My .Rprofile file is as follows (credit to this source):
VIRTUALENV_NAME = "virt_tf"
if (Sys.info()[["user"]] == "shiny"){
# Running on shinyapps.io
Sys.setenv(PYTHON_PATH = 'python3')
Sys.setenv(VIRTUALENV_NAME = VIRTUALENV_NAME) # Installs into default shiny virtualenvs dir
Sys.setenv(RETICULATE_PYTHON = paste0('/home/shiny/.virtualenvs/', VIRTUALENV_NAME, '/bin/python'))
} else if (Sys.info()[["user"]] == "rstudio-connect"){
# Running on remote server
Sys.setenv(PYTHON_PATH = '/opt/python/3.7.6/bin/python')
Sys.setenv(VIRTUALENV_NAME = paste0(VIRTUALENV_NAME, '/')) # include '/' => installs into rstudio-connect/apps/
Sys.setenv(RETICULATE_PYTHON = paste0(VIRTUALENV_NAME, '/bin/python'))
} else {
# Running locally
options(shiny.port = 7450)
Sys.setenv(PYTHON_PATH = 'python 3.6.12')
Sys.setenv(VIRTUALENV_NAME = VIRTUALENV_NAME) # exclude '/' => installs into ~/.virtualenvs/
# RETICULATE_PYTHON is not required locally, RStudio infers it based on the ~/.virtualenvs path
}
The deployment process seems to run completely according to R log:
rsconnect::deployApp()
Preparing to deploy application...Update application currently deployed at
https://name.shinyapps.io/appname/? [Y/n] y
DONE
Uploading bundle for application: 3428026...DONE
Deploying bundle: 4035381 for application: 3428026 ...
Waiting for task: 846214175
building: Parsing manifest
building: Building image: 4594673
building: Installing system dependencies
building: Fetching packages
building: Installing packages
building: Installing files
building: Pushing image: 4594673
deploying: Starting instances
terminating: Stopping old instances
Application successfully deployed to https://name.shinyapps.io/appname/
The error I get from the bottom of the log:
Error in value[[3L]](cond) : Installation of TensorFlow not found.
Python environments searched for 'tensorflow' package:
You can install TensorFlow using the install_tensorflow() function.
/home/shiny/.virtualenvs/virt_tf/bin/python3
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
When I try to include tensorflow into the list of packages required to be installed into my virtualenvironment I get the following error message:
Downloading tensorflow-2.3.1-cp35-cp35m-manylinux2010_x86_64.whl (320.4 MB)
Collecting tensorflow
Killed
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Error in value[[3L]](cond) :
Error installing package(s): 'numpy', 'h5py', 'scipy', 'scikit-image', 'pyyaml', 'pillow', 'tensorflow'
Execution halted
Out of memory!
As far as I understand, shinyapps.io pushes me to install tensorflow package into virtualenvironment. However, I guess, it should be in the list of available packages. But how to force using it?
This looks like an issue that might require changes to shinyapps or rsconnect. Please file an issue on github if you're still experiencing this.

Unable to Install devtools in R on Jenkins

I'm building a Jenkins Job to test a library.
I'm doing most of the scripts work in the r-base docker image.
When I try to install dev tools via Rscript -e
dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) # create personal library
.libPaths(Sys.getenv("R_LIBS_USER")) # add to the path
install.packages("devtools")
install_allstate_github <- function(user, repo, ...) {
tmp_dir <- "$app_dir/ravenclaw"
devtools::install(tmp_dir, dependencies = TRUE)
}
install_allstate_github("SortingHat", "ravenclaw")
library(ravenclaw)
I get the following error
Warning message:
In dir.create(Sys.getenv("R_LIBS_USER"), recursive = TRUE) :
'/export/home/compjenk/workspace/ISG-Sorting-Hat/Ravenclaw/r-libs' already exists
Installing package into ���/export/home/compjenk/workspace/ISG-Sorting-Hat/Ravenclaw/r-libs���
(as ���lib��� is unspecified)
Warning: unable to access index for repository https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib:
cannot open URL 'https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib/PACKAGES'
Warning messages:
1: In gzfile(file, "rb") :
cannot open compressed file '/tmp/RtmpQGoABw/repos_https://****:****#artifactory.allstate.com/artifactory/cran/src/contrib.rds', probable reason 'No such file or directory'
2: package ���devtools��� is not available (for R version 4.0.2)
Error in loadNamespace(name) : there is no package called ���devtools���
Calls: install_allstate_github ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart
Execution halted
I've set the corporate CRAN server in .Rprofile as well as Proxy information but it doesn't seem to help.
.Rprofile
local({
r <- list("cran" = "https://****:****#artifactory.allstate.com/artifactory/cran/")
options(repos = r)
options(RCurlOptions = list(ssl.verifypeer = FALSE,
ssl.verify = FALSE,
proxy = "http://webproxy:8080"))
#set_config( config( ssl_verifypeer = 0L ) )
Sys.setenv(http_proxy = "http://webproxy:8080")
Sys.setenv(https_proxy = "https://webproxy:8080")
So What am I missing or doing wrong? why can't I install devTools?

nss 3.35 issue with nspr 4.19 PR_GetEnvSecure function

I am getting the following error while building nss 3.35 version
secoid.c:(.text.SECOID_Init+0x36): undefined reference to PR_GetEnvSecure'
secoid.c:(.text.SECOID_Init+0x55): undefined reference toPR_GetEnvSecure'
I am using nspr version 4.19 to build this.
Here is my command to build nss
make -j1 BUILD_OPT=1 NSPR_INCLUDE_DIR=nss-3.36.1/nspr/include/nspr USE_SYSTEM_ZLIB=1 ZLIB_LIBS=-lz NSS_ENABLE_WERROR=0 $([ $(uname -m ) = x86_64 ] && echo USE_64=1 ) $([ -f /usr/include/sqlite3.h ] && echo NSS_USE_SYSTEM_SQLITE=1 )
This is a similar issue reported in Red Hat Bugzilla 1458841.
In that case they removed the dependency on this object.
In Red Hat 7.6 this object is defined in library "/lib64/libnspr4.so" as you can see below.
objdump -TC /lib64/libnspr4.so | grep PR_GetEnvSecure
0000000000019b60 g DF .text 0000000000000067 Base PR_GetEnvSecure
You need to build NPSR library version that defines this object, for example version 4.19

R shiny segfaulting

I have just installed shiny 1.0.5 in Ubuntu 14.04.5 LTS and am receiving a segmentation fault on the default landing page. The last bit of the Javascript console/hello error log is:
89: .Call("httpuv_run", PACKAGE = "httpuv", timeoutMillis)
90: run(timeoutMs)
91: service(timeout)
92: serviceApp()
93: withCallingHandlers(expr, error = function(e) { if (is.null(attr(e, "stack.trace", exact = TRUE))) { calls <- sys.calls() attr(e, "stack.trace") <- calls stop(e) }})
94: captureStackTraces({ scheduleFlush() while (!.globals$stopped) { serviceApp() Sys.sleep(0.001) }})
95: ..stacktraceoff..(captureStackTraces({ scheduleFlush() while (!.globals$stopped) { serviceApp() Sys.sleep(0.001) }}))
96: runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
An irrecoverable exception occurred. R is aborting now ...
-su: line 1: 2739 Segmentation fault (core dumped) R --no-save --slave -f \/opt\/shiny-server\/R\/SockJSAdapter\.R
Also, from the beginning of the log file:
*** caught segfault ***
address 0xbd, cause 'memory not mapped'
Any tips on debugging this and getting it running?
I don't ultimately know what the issue is, but upgrading to R 3.4.2 had completely broken Shiny. Removing r-base (r-base-core, etc) via apt and reinstalling 3.3.3 fixed the issue, though it remains frustrating.

Puppet syncing dir

Still does not work
In/etc/puppet/manifests/site.pp
file { "/home/render/installation/":
ensure => "directory",
owner => "render",
group => "render",
recurse => "true",
mode => "0750",
source => "puppet:///files/installation/",
}
Dir still is empty on client
ls /etc/puppet/files/installation/
1 2 3 4 5
On puppet client in log
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Failed to generate additional resources using 'eval_generate: Error 400 on SERVER: Not authorized to call search on /file_metadata/files/installation with {:checksum_type=>"md5", :recurse=>true, :links=>"manage"}
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Could not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation Could not retrieve file metadata for puppet:///files/installation: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation
Mar 21 12:28:12 lw-003 puppet-agent[28098]: Finished catalog run in 0.28 seconds
I had the same issue and found this question on Google. I had to change the path to the files for the manifests (modulename/manifests/init.pp):
"puppet:///files/installation/",
to:
"puppet:///modules/files/installation/",
The notation without /modules/ was deprecated in 2.7 and no longer supported in newer versions:
DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module 'modulename' when no 0.24.x clients are present
try this example,
file {
"/scratch/usern/testmod" :
ensure => directory,
source => "puppet:///files/testmod",
recurse => true,
owner => "usern",
group => "groupn",
mode => "0775",
backup => false,
}
You have to specify 'files' and if you are doing a recursive copy, specify 'recurse => true'. That might be the solution to your problem.
the 'fileserver.conf' should look something like the following :
]# cat /etc/puppet/fileserver.conf
[files]
path /etc/puppet/files
allow *

Resources