rstudio / rsconnect

Publish Shiny Applications, RMarkdown Documents, Jupyter Notebooks, Plumber APIs, and more
http://rstudio.github.io/rsconnect/
131 stars 79 forks source link

My .env file is not visible when deploying app on shiny server #972

Closed tatjana-lebesgue closed 11 months ago

tatjana-lebesgue commented 11 months ago

I could not deploy my app on shiny server:

aronatkins commented 11 months ago

Could you tell us more about your project and how you are attempting to deploy?

I just tried the following steps and the .env file was selected when deploying:

# create a new project
usethis::create_project("~/Desktop/using-env")
# within this project, create a skeleton shiny app
# and an .env file.
writeLines(c(
        "shinyApp(ui = fluidPage('having an environment.'), server = function(input, output){})"
    ), "app.R")
writeLines(c(
        "# the .env file"
    ), ".env")

I then used the "publish" icon:

image
tatjana-lebesgue commented 11 months ago

I am using same way to deploy app on shiny server, selecting files from rstudio and clicking on publish icon:

Screenshot 2023-08-22 at 20 06 28

My ui is dashboardPage with a lot of elements I dont know which details are important. But I know that when I try to deploy using rsconnect version 0.8.29 I can see my .env file (but cant deploy)

aronatkins commented 11 months ago

@tatjana-lebesgue I have somehow managed to get one of my projects into the same state. I'm continuing to dig. I'm not sure the cause nor a workaround at this point.

aronatkins commented 11 months ago

With rsconnect-0.8.29:

> rsconnect::listBundleFiles(getwd())$contents
[1] ".env"  "app.R"

With rsconnect-1.0.2:

> rsconnect::listBundleFiles(getwd())$contents
[1] "app.R"
aronatkins commented 11 months ago

The .env directory is now regarded as a well-known path for Python virtual environments:

https://github.com/rstudio/rsconnect/blob/0d052a0f6164e5f2a95a0e9e94c85a804ecf6672/R/bundleFiles.R#L182-L184

This was done in https://github.com/rstudio/rsconnect/pull/700

@tatjana-lebesgue - is it possible to rename that .env file, perhaps to .Renviron? Are you using other tools which expect the .env filename?

I'm continuing to see if we can allow .env files again, but in the mean time, using some other name should let you deploy again.

tatjana-lebesgue commented 11 months ago

I did that, and now it's working! I was using the 'dotenv' package and then was expecting the '.env' filename (regards consistency in other projects).

Thank you for the quick response and help @aronatkins :)

aronatkins commented 11 months ago

@tatjana-lebesgue The development version of rsconnect should let you use .env files once again.

remotes::install_github("rstudio/rsconnect")

Please let us know if you encounter any other difficulties.