Error when launching shiny app in EC2 instance

2019-08-24 01:22发布

I have a shiny application setup in my EC2 instance. The application is simple, and uses a CSV file that I have saved in an S3 bucket (that has public read access). For more info on my setup, I followed the instructions in this article - https://aws.amazon.com/blogs/big-data/running-r-on-aws/ - to a dot, and I am able to deploy their demo app.

I have RStudio Server on my EC2 instance, and I have the code to run the app saved in the appropriate place in my EC2 instance (ec2-user/ShinyApps/myappnamehere/app.R. However, when I attempt to go to the url with my shiny app - http://ec2-MY-IP.compute-1.amazonaws.com:3838/ec2-user/myappnamehere/, I receive the following error at that url:

An error has occurred
The application failed to start.
The application exited during initialization.

This is odd because when I hit 'run app' from RStudio Server in the console, the app launches perfectly and works fine. I've investigated by going into ec2-user/ShinyApps/log directory, and looking at the log file from when I attempted to visit the app online, and it is as follows:

su: ignore --preserve-environment, it's mutually exclusive to --login.
Error in library(RCurl) : there is no package called ‘RCurl’
Calls: runApp ... sourceUTF8 -> eval -> eval -> ..stacktraceon.. -> library
Execution halted

This is odd because while, yes, library(RCurl) is a line in my code (the second line actually), THIS CODE WORKS (the whole app works) when I run it in RStudio Server.

Any thoughts on why this might not be working would be greatly appreciated!

EDIT - not sure if this is the best place for this post, since it isn't on a specific line of code - if not, please point me in the right direction.

1条回答
Anthone
2楼-- · 2019-08-24 02:08

To install packages so that they are available for all users. You need to install the packages as super-user.

First you want to run R as sudo.

I preferably do with first switch to su with

sudo su

the run R by just typing R .

Then install all packages you need.

This will make all installed packages available to all users including shiny

查看更多
登录 后发表回答