datawookie/emayili

[BUG]: Cannot deploy to shinyapps.io

DavidL-H opened this issue · 12 comments

Description of the bug

I have a shiny app that uses Emayili. When I run it locally, it works as expected, but when I try to deploy it to my shinyapps.io account, it gives this error message:

Preparing to deploy application...DONE
Uploading bundle for application: 6506012...Error: Unable to retrieve package records for the following packages:
- "email"
In addition: Warning message:
In FUN(X[[i]], ...) :
  Package 'email' not available in repository or locally
Execution halted

Maybe I am missing something basic, but don't under why the error message is refering to a package "email" that is not installed.

Steps To Reproduce

ui.R

library(shiny)
shinyUI(fluidPage(

    titlePanel("Emayili Shiny test"),

    sidebarLayout(
        sidebarPanel(
              actionButton("SendEmail", "Send Email"),
        ),

        mainPanel(
        )
    )
))

server.R

library(shiny)
library(emayili)
shinyServer(function(input, output) {
      observeEvent(input$SendEmail,{
            smtp <- server(
                  host = "smtp.gmail.com",
                  port = 465,
                  username = "my gmail account",
                  password = "my password"
            )
            
            email <- envelope()
            email <- email %>%
                  from("my gmail account") %>%
                  to("recipient")%>% 
                  subject(paste("Test email"))%>% 
                  text("This work locally, but cannot be deployed too shinyapps.io")
            
            smtp(email, verbose = TRUE)
      })

})

Additional Information

sessionInfo()

R version 4.2.0 (2022-04-22 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C                           LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] readr_2.1.2          openxlsx_4.2.5       dplyr_1.0.9          rdrop2_0.8.2.1       stringr_1.4.0        readxl_1.4.0         emayili_0.7.10      
[8] shinydashboard_0.7.2 shiny_1.7.1         

loaded via a namespace (and not attached):
 [1] httr_1.4.3                 sass_0.4.1                 tidyr_1.2.0                jsonlite_1.8.0             assertive.sets_0.0-3      
 [6] bslib_0.3.1                askpass_1.1                assertive.data_0.0-3       triebeard_0.3.0            urltools_1.7.3            
[11] cellranger_1.1.0           pillar_1.7.0               glue_1.6.2                 assertive.matrices_0.0-2   assertive.data.uk_0.0-2   
[16] digest_0.6.29              assertive.types_0.0-3      promises_1.2.0.1           rvest_1.0.2                htmltools_0.5.2           
[21] httpuv_1.6.5               pkgconfig_2.0.3            assertive.properties_0.0-5 assertive.data.us_0.0-2    assertive.reflection_0.0-5
[26] logger_0.2.2               purrr_0.3.4                xtable_1.8-4               later_1.3.0                assertive_0.3-6           
[31] tzdb_0.3.0                 openssl_2.0.2              tibble_3.1.7               generics_0.1.2             ellipsis_0.3.2            
[36] DT_0.23                    cachem_1.0.6               withr_2.5.0                assertive.code_0.0-3       cli_3.3.0                 
[41] magrittr_2.0.3             crayon_1.5.1               assertive.strings_0.0-3    mime_0.12                  evaluate_0.15             
[46] fansi_1.0.3                assertive.numbers_0.0-2    xml2_1.3.3                 data.table_1.14.2          rsconnect_0.8.26          
[51] tools_4.2.0                hms_1.1.1                  lifecycle_1.0.1            assertive.files_0.0-2      zip_2.2.0                 
[56] compiler_4.2.0             jquerylib_0.1.4            rlang_1.0.2                rstudioapi_0.13            htmlwidgets_1.5.4         
[61] assertive.models_0.0-2     assertive.base_0.0-9       base64enc_0.1-3            rmarkdown_2.14             codetools_0.2-18          
[66] curl_4.3.2                 assertive.datetimes_0.0-3  R6_2.5.1                   knitr_1.39                 fastmap_1.1.0             
[71] utf8_1.2.2                 commonmark_1.8.0           stringi_1.7.6              Rcpp_1.0.8.3               vctrs_0.4.1               
[76] tidyselect_1.1.2           xfun_0.31           

Package 'email' not available in repository or locally

Looks like somewhere in the files which you are uploading to shinyapps.io you're referring to a package called "email". That's not an {emayili} problem though...

Thanks for the quick answer. I don't have much experience with Shiny apps, so sorry if this is the wrong place for the issue. But error message comes only when I have library(emayili) in the app (see steps to reproduce above). Nothing else is called other than ibrary(shiny). When I comment out the library call and code related to emayili, it deploys just fine:

library(shiny)
#library(emayili)
# Define server logic required to draw a histogram
shinyServer(function(input, output) {
      observeEvent(input$SendEmail,{
            # smtp <- server(
            #       host = "smtp.gmail.com",
            #       port = 465,
            #       username = "my gmail account",
            #       password = "my password"
            # )
            # 
            # email <- envelope()
            # email <- email %>%
            #       from("my gmail account") %>%
            #       to("recipient")%>% 
            #       subject(paste("Test email"))%>% 
            #       text("This work locally, but cannot be deployed too shinyapps.io")
            # 
            # smtp(email, verbose = TRUE)
      })

})

Sorry, but it seems to work for me. I've used the code you supplied and deployed to shinyapps.io. Evidently there's something in your project that is not included in the initial information that you sent me (the ui.R and server.R files).

image

Yeah, must be another issue then. Thanks for your quick help!

Do you have any other files in this project? Or is it just the ui.R and server.R files? And are they verbatim copies of the code that you provided in the original question?

I'm trying to use the emayili package for a larger shiny project, the deloyment of which stopped working when I included emayili. For the reproducible example I posted above, I have nothing else in the project, just the ui and server files. They are verbatim copies of what I posted.

Hi @DavidL-H, I'd like to help you resolve this problem. Do you have time for a quick call sometime this week? I'm full committed for the next two days, but I'll have time on Wednesday. Thanks, Andrew.

Thanks you very much for the offer @datawookie, I appreciate it, but I actually just found a work around, and now it works.
The original server.R

library(shiny)
library(emayili)
shinyServer(function(input, output) {
      observeEvent(input$SendEmail,{
            smtp <- server(
                  host = "smtp.gmail.com",
                  port = 465,
                  username = "my gmail account",
                  password = "my password"
            )
            
            email <- envelope()
            email <- email %>%
                  from("my gmail account") %>%
                  to("recipient")%>% 
                  subject(paste("Test email"))%>% 
                  text("This work locally, but cannot be deployed too shinyapps.io")
            
            smtp(email, verbose = TRUE)
      })
})

Gave an error when deploying to shiny, that it could not find package email. After some testing, it seems that shiny thinks that the email object being assigned the mail which is sent emayili, is a package, for some reason that I still don't understand. Changing the server.R to:

library(shiny)
library(emayili)
shinyServer(function(input, output) {
      observeEvent(input$SendEmail,{
            smtp <- server(
                  host = "smtp.gmail.com",
                  port = 465,
                  username = "my gmail account",
                  password = "my password"
            )
            
            another_name<- envelope()
            another_name<- another_name%>%
                  from("my gmail account") %>%
                  to("recipient")%>% 
                  subject(paste("Test email"))%>% 
                  text("This work locally, but cannot be deployed too shinyapps.io")
            
            smtp(another_name, verbose = TRUE)
      })
})

gave the following error:

Preparing to deploy application...DONE
Uploading bundle for application: 6506012...Error: Unable to retrieve package records for the following packages:
- "another_name"
In addition: Warning message:
In FUN(X[[i]], ...) :
  Package 'another_name' not available in repository or locally
Execution halted

However, to work around this I changed the code to:

library(shiny)
library(emayili)
shinyServer(function(input, output) {
      observeEvent(input$SendEmail,{
            smtp <- server(
                  host = "smtp.gmail.com",
                  port = 465,
                  username = "my gmail account",
                  password = "my password"
            )
            
            emayili<- envelope()
            emayili<- emayili%>%
                  from("my gmail account") %>%
                  to("recipient")%>% 
                  subject(paste("Test email"))%>% 
                  text("I can now deploy my app to shinyapps.io")
            
            smtp(emayili, verbose = TRUE)
      })
})

And now the app deploys to shinyapps.io just fine and is working as expected. Weird.

Very weird indeed. Well the original code worked fine for me (locally and on shinyapps). I'm guessing that we might be seeing different versions of shinapps (maybe they are doing some beta testing?). Your hack is very clever... but I think that this immediately indicates that something weird is going on in shinyapps and this is not an {emayili} issue!

Hi, I am trying to build an app to send email. I copied and paste this code to see if it works. Well, it doesn't work locally. I am getting this error:
Warning: Error in server: unused arguments (host = "smtp.gmail.com", port = 465...) 1: runApp

Do you know what it may be? Thanks

Hi @andresimi, please can you create a new issue since this one is closed. Also, please can you provide:

  • the code that you are running (obfuscate all sensitive information like passwords)
  • version of R and
  • version of {emayili} package.

Thanks, Andrew.

@datawookie thank you, i just did it