Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shiny app containing rintrojs code won't run in VSCode #1574

Open
David-Kingman opened this issue Nov 8, 2024 · 0 comments
Open

Shiny app containing rintrojs code won't run in VSCode #1574

David-Kingman opened this issue Nov 8, 2024 · 0 comments
Labels

Comments

@David-Kingman
Copy link

I have a shiny app which I originally developed using RStudio which I have been trying to run locally in VSCode (in both cases on a Windows 10 virtual machine). However, this doesn't work because of an error which only occurs when I try and run the app in VSCode, and not when I run exactly the same code in RStudio with the same version of R and the same package versions.

It appears to be being caused by the inclusion of code from the rintrojs library which includes some characters which VSCode thinks are invalid UTF-8 characters, triggering an error, but which RStudio does not have a problem with.

This is the error message I get in VSCode:
image

I have managed to create a minimally reproducible example of the problem I get in my app (I have highlighted the line which is causing the error):

library(shiny)
library(rintrojs)

# Define UI for application that draws a histogram
ui <- fluidPage(
  
  # Commenting the line below out stops the error from happening in VSCode, whereas including it is what triggers the error!
  rintrojs::introjsUI(),

    # Application title
    titlePanel("Old Faithful Geyser Data"),

    # Sidebar with a slider input for number of bins 
    sidebarLayout(
        sidebarPanel(
            sliderInput("bins",
                        "Number of bins:",
                        min = 1,
                        max = 50,
                        value = 30)
        ),

        # Show a plot of the generated distribution
        mainPanel(
           plotOutput("distPlot")
        )
    )
)

# Define server logic required to draw a histogram
server <- function(input, output) {

    output$distPlot <- renderPlot({
        # generate bins based on input$bins from ui.R
        x    <- faithful[, 2]
        bins <- seq(min(x), max(x), length.out = input$bins + 1)

        # draw the histogram with the specified number of bins
        hist(x, breaks = bins, col = 'darkgray', border = 'white',
             xlab = 'Waiting time to next eruption (in mins)',
             main = 'Histogram of waiting times')
    })
}

# Run the application 
shinyApp(ui = ui, server = server)

I can run this code in RStudio with the line I have highlighted either included or not included and the app will load. However, if I leave that line in the code and try and run it in VSCode, then it will produce the error message I have shared above.

I have identified the characters which trigger the error message and they actually originate in the javascript package which that R function is providing a wrapper around, so I am not sure to what extent this is a R issue.

Environment (please complete the following information):

  • OS: Windows 10
  • VSCode Version: 1.90.1
  • R Version: 4.4.1
  • vscode-R version: 2.8.4
  • rintrojs Version: 0.3.2
  • shiny Version: 1.9.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant