Calling getwd() from within a shiny app



I am creating a Shiny app that needs to access a user's working directory. I assumed getwd() would work from within the Shiny app, however this always points to the directory of the Shiny app itself.


From the R console:

[1] "/Users/chris.harrison/Documents"

From the following Shiny app saved on the desktop:


ui <- fluidPage(

server <- function(input, output){
 output$wd <- renderText(getwd())

shinyApp(ui = ui, server = server)

And then calling:


the output is:


Is there any way to call the user's working directory from within the app?

Many thanks,



It's not obvious to me why you would want to do this or why your users would want to allow this. Nonetheless, the first thing that comes to mind is that you might be interested in R's file manipulation capabilities either through base R or a package like fs.


I really don't think there is. Shiny will always set the working directory as it runs.

Can you say why you want to and there might be something else you could do instead?