rstudio / shiny-server

Host Shiny applications over the web.
https://rstudio.com/shiny/server
Other
712 stars 291 forks source link

Cannot use relative path for site_dir parameter in shiny-server.conf #571

Open heckelson opened 1 month ago

heckelson commented 1 month ago

my setup

I am using shiny-server with a config file located at the base of my repository (./shiny-server.conf). Installed through the Arch Linux AUR.

Like this: $ shiny-server shiny-server.conf.

I have put my app under ./shiny-app/apps/hello such that the dir structure is now:

./shiny-app/apps/hello/
├── filtered_samples.csv
├── norm_count_mtx.csv
├── results.csv
├── server.R
└── ui.R

My shiny-server.conf looks like this:

run_as alex;

server {
  listen 8888;

  location / {
    site_dir ./shiny-app/apps;
    log_dir ./shiny-app/logs;
    bookmark_state_dir ./shiny-app/bookmarks;

    directory_index on;
  }
}

the problem

While shiny-server seems to be able to handle log_dir and bookmark_state_dir being relative, it logs the following once I visit localhost:8888/hello/ (it logs it inside the log_dir):

Error in `shinyAppDir()`:
! No Shiny application exists at the path "shiny-app/apps/hello"
Backtrace:
    ▆
 1. └─shiny::runApp(Sys.getenv("SHINY_APP"), port = port, launch.browser = FALSE)
 2.   ├─shiny::as.shiny.appobj(appDir)
 3.   └─shiny:::as.shiny.appobj.character(appDir)
 4.     └─shiny::shinyAppDir(x)
 5.       └─rlang::abort(...)
Ausführung angehalten (this is German for "stopped execution")

HOWEVER, once I replace site_dir with the absolute path, i.e. /home/alex/repos/my_repo/shiny-app/apps, it can find the app just fine.

In other words, the line now looks like this:

    ...
    location / {
        site_dir /home/alex/repos/my_repo/shiny-app/apps;
    ...

I don't think this is intended behavior, which is why I'm reporting this.