Write and Read keys in rEnvironment in Shiny - r

can someone help me with this?
Im setting up a map with maptiles by mapbox on shinyapps.io.
I saved the mapbox token in the rEnvironment. This command is not in the server-side of shiny and is run just once, when starting the script. Followed by readRenviron("~/.Renviron") to load all keys etc.
In the server-side before needed in leaflet I call Sys.getenv("MAPBOX_PUBLIC_TOKEN")
I get this error and the application shuts down
2022-11-28T08:26:09.047038+00:00 shinyapps[7740855]: A MAPBOX_PUBLIC_TOKEN already exists. You can overwrite it with the argument overwrite=TRUE 2022-11-28T08:26:09.047050+00:00 shinyapps[7740855]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous> 2022-11-28T08:26:09.047054+00:00 shinyapps[7740855]: Execution halted
Is it the wrong way around? I tried many different ways.

Related

Error in enforcePackage(name, curVersion) : The shiny package was not found in the library

I'm trying to deploy a shiny app to shinyapps server. the app works just fine locally and when deploying using rsconnect::deployApp() I can see the message Application successfully deployed to in the console but actually on browser is not working and showing the following:
Error in enforcePackage(name, curVersion) : The shiny package was not found in the library. Calls: local ... eval -> eval -> eval -> <Anonymous> -> enforcePackage. Execution halted
Shiny package is loaded of course.
Also when trying to run rsconnect::appDependencies() the following error pop-up :
Error in [.data.frame(deps, , "Package") : undefined columns selected
Thank you all in advance for your help

How to stop R shiny session or R script without stack trace?

I have complex code and I have two withCallingHandlers that handle errors. and I want to call stop() to stop R or shiny session but I have a long stacktrace. I've tried:
invokeRestart("abort")
but then I've got error:
Error in execCallbacks(timeoutSecs, all, loop$id) :
Calls: <Anonymous> ... ..stacktracefloor.. -> serviceApp -> service -> run_now -> execCallbacks
Execution halted
is it possible to stop R without stack trace? Note that I can't call quit(), since this will stop all shiny sessions.

Shiny server not working after update to 1.5

I had a shiny app working using shiny-server 1.4.2.786 and after upgrading to 1.5.9.923 and I get the following error:
Error in if (nchar(bookmarkStateDir) > 0) { :
missing value where TRUE/FALSE needed
Calls: local -> eval.parent -> eval -> eval -> eval -> eval
Execution halted
If I roll back to 1.4.2.786, everything works as expected, therefore I don't think it's an issue with permissions or general shiny config files. Any idea what this is due to? I couldn't find any solutions online, however, I did read that 1.5 introduces big changes in Node.js, so perhaps this causes errors? Thanks!

gzfile error when publishing Shiny app

I'm trying to publish an R Shiny app. It works when run locally, but once published to shinyapps.io produces the following error.
Warning in gzfile(file, "wb") :
cannot open compressed file '/key.rda', probable reason 'Permission denied'
Error in value[[3L]](cond) : cannot open the connection
Calls: local ... tryCatch -> tryCatchList -> tryCatchOne -> <Anonymous>
Execution halted
You can also see the actual page with the error here: https://povertylab.shinyapps.io/ACS-Map-Dashboard/
Though I have tried to reproduce this error it doesn't appear when I publish other apps, and my searches haven't turned up anything. Other things I've tried: publishing from other computers, publishing only global.R, server.R, and ui.R files, and copying files to a new project and publishing from there.
You can find all code for the app here: https://github.com/Poverty-Lab/ACS-Map-Dashboard
I would appreciate any input, even if it's just guidance on what gzfile is and what the error message could mean. Thank you!
Where is the key.rda file supposed to be? I've looked through your repo and I don't see it, which is probably causing the "cannot open the connection" error.
As a side note, you should probably ignore the .Renviron file; right now anyone can use see and use your key. Make sure you remove it from the history as well.
Thanks all. Turns out this was a problem with the way we were handing the api key for the acs package. We were using api.key.install to install the api key inside the app, and one of api.key.install's default arguments is file = "key.rda", and that file apparently could not be found. I'm still not sure why this problem only came up when we published the app, but we got around it by supplying the actual api key to the acs.fetch function in server.R.

The app is disconnected after a second

I ran shiny app in linux.
I open the browser in the url: http://192.241.147.231:4949/sample-apps/MonitorUI/
The page is open but after a second disconnected.
I check the log file and it write to me this massage:
Error in eval(expr, envir, enclos) :
You are attempting to load an rmarkdown file, but the
rmarkdown package was not found in the library. Ensure that
rmarkdown is installed and is available in the Library of the
user you're running this application as.
Calls: local -> eval.parent -> eval -> eval -> eval -> eval
Execution halted
I already downloaded the "rmarkdown" package. and it updated.
What is the problem? i don't find anything for this problem in the web.
the sample app that given by shiny-server package:http://192.241.147.231:4949/sample-apps/hello/ is working so what is the problem?
Thanks.

Resources