You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Ubuntu升级R 4.3.3与Shiny 1.8.0后无法运行,报逻辑coercion错误

升级R 4.3.3与Shiny 1.8.0后Shiny应用运行报错解决方案

问题概述

Ubuntu 16.04系统升级至R 4.3.3和Shiny 1.8.0后,运行Shiny应用出现如下错误:

Error in is.call(funBody[[idx]]) && as.character(funBody[[idx]][[1]]) == : 'length = 3' in coercion to 'logical(1)'

系统详情

R version 4.3.3 (2024-02-29)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.7 LTS

矩阵运算:默认
BLAS:   /usr/lib/libblas/libblas.so.3.6.0 
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

区域设置:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

时区: Etc/UTC
时区代码来源: 系统(glibc)

已附加的基础包:
[1] stats     graphics  grDevices utils     datasets  methods   base     

其他已附加包:
[1] stringr_1.5.1 shiny_1.8.0  

通过命名空间加载(未附加):
 [1] crayon_1.5.2      cli_3.6.2         rlang_1.1.3       stringi_1.8.3     promises_1.2.1    jsonlite_1.8.8    xtable_1.8-4     
 [8] glue_1.7.0        htmltools_0.5.7   httpuv_1.6.14     sass_0.4.8        jquerylib_0.1.4   ellipsis_0.3.2    fastmap_1.1.1    
[15] yaml_2.3.8        lifecycle_1.0.4   memoise_2.0.1     compiler_4.3.3    Rcpp_1.0.12       rstudioapi_0.15.0 later_1.3.2      
[22] digest_0.6.35     R6_2.5.1          magrittr_2.0.3    bslib_0.6.1       tools_4.3.3       withr_3.0.0       mime_0.12        
[29] cachem_1.0.8

应用代码

ui.R

library(shiny)

shinyUI(fluidPage(
                  titlePanel(title="Title", windowTitle = "Window Title"),br(),
                  tabPanel("",
                           navbarPage("",inverse = T, id="oneClickTabPanel"
                                    
                           )
                  )
)
)

server.R

library(shiny)

shinyServer(function(input, output, session) {
    
    output$columnLookupDataFileUi <- renderUI({
        t<-div("OK")
        t
    })
})

完整报错栈

Listening on http://127.0.0.1:4357
Warning: Error in &&: 'length = 3' in coercion to 'logical(1)'
  49: .rs.findBreakpointSteps
  48: .rs.findBreakpointSteps
  47: .rs.findBreakpointSteps
  46: .rs.findBreakpointSteps
  45: .rs.removeBreakpoints
  44: registerShinyDebugHook
  43: registerDebugHook
  42: wrapFunctionLabel
  41: .subset2(x, "impl")$defineOutput
  40: $<-.shinyoutput
  38: server [./server.R#5]
   1: runApp

报错原因分析

从报错栈可见,错误源自RStudio内部调试函数(.rs.*前缀),说明问题并非Shiny应用代码本身,而是旧版本RStudio与新版R/Shiny的调试功能不兼容,或是当前会话中残留的断点、调试钩子引发冲突。Ubuntu 16.04属于老旧系统,配套的RStudio版本通常无法完全适配R 4.3.3的新特性。

解决方案

按以下步骤逐一尝试:

1. 清除所有断点

  • 在RStudio中使用快捷键 Ctrl+Shift+F9 清除所有断点
  • 或在控制台运行命令:
    rstudioapi::removeAllBreakpoints()
    

2. 更新rstudioapi包

控制台运行:

install.packages("rstudioapi")

3. 升级RStudio至兼容版本

由于Ubuntu 16.04已停止官方支持,需选择仍兼容该系统的RStudio版本(如RStudio 2022.07.x系列),手动下载安装:

# 示例:下载并安装适配Ubuntu 16.04的RStudio版本
wget https://download1.rstudio.org/desktop/bionic/amd64/rstudio-2022.07.2-576-amd64.deb
sudo dpkg -i rstudio-2022.07.2-576-amd64.deb
sudo apt-get install -f

4. 脱离RStudio环境运行

若无法升级RStudio,可尝试在终端直接运行R,规避RStudio的调试干扰:

R

在终端R会话中执行:

library(shiny)
runApp("你的应用目录路径")

内容的提问来源于stack exchange,提问作者guna

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 04:58:11