'Why does my shiny app return invalid utf-8?

I keep getting this when I run my shiny app with the error;

Warning: Error in sub: 'replacement' is invalid UTF-8
  [No stack trace available]

Before this error, the App has been running with no problem and nothing has been changed in the code. I have tried all I can to get to the root of the problem but to no avail. Any idea pointers to what could be causing this?

enter image description here

I suspect this to be causing the error

renv_json_read <- function(file = NULL, text = NULL) {
    
    text <- paste(text %||% read(file), collapse = "\n")
    
    # find strings in the JSON
    pattern <- '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
    locs <- gregexpr(pattern, text)[[1]]
    
    # if any are found, replace them with placeholders
    replaced <- text
    strings <- character()
    replacements <- character()
    
    if (!identical(c(locs), -1L)) {
      
      # get the string values
      starts <- locs
      ends <- locs + attr(locs, "match.length") - 1L
      strings <- substring(text, starts, ends)
      
      # only keep those requiring escaping
      strings <- grep("[[\\]{}:]", strings, perl = TRUE, value = TRUE)
      
      # compute replacements
      replacements <- sprintf('"\032%i\032"', seq_along(strings))
      
      # replace the strings
      mapply(function(string, replacement) {
        replaced <<- sub(string, replacement, replaced, fixed = TRUE)
      }, strings, replacements)
      
    }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source