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

上传Shiny应用至shinyapps.io时出现Object Not Found错误的排查咨询

Troubleshooting "object 'BPT' not found" Error on shinyapps.io

Hey there, let's dig into why your Shiny app works perfectly in RStudio locally but throws that frustrating object 'BPT' not found error when deployed to shinyapps.io. Here are the key things to check, step by step:

1. Verify How BPT is Defined and Loaded

  • Check scope: Is BPT created in a global context (like global.R) or only inside a local function in server.R? If it's stuck in a local scope, shinyapps.io's server environment won't be able to access it. Make sure code that creates BPT runs before the server function starts—global.R is the safest place for shared objects.
  • Local data file dependencies: If BPT comes from a CSV/Excel file (e.g., BPT <- read.csv("BPT_data.csv")), double-check that:
    • The data file is in the same folder as your app code (ui.R/server.R/global.R)
    • You're using a relative path (not an absolute path like C:/Users/YourName/Documents/BPT_data.csv—shinyapps.io can't access your local file system)
    • The file was included when you deployed the app (more on that next)
  • Package dependencies: If BPT is generated using functions from a package (e.g., dplyr, readxl), make sure you explicitly load the package in global.R or at the top of your app script. For example:
    library(dplyr)
    library(readxl)
    
    Shinyapps.io installs packages automatically, but if you skip loading them, the functions needed to create BPT won't be available.

2. Confirm All Required Files Are Deployed

  • When you hit "Publish" in RStudio, a window pops up showing which files will be uploaded to shinyapps.io. Take a close look—did you include the data file that generates BPT? Did you include global.R if that's where BPT is defined?
  • If you added files after setting up the deployment, they might not be selected by default. Try re-selecting all relevant files, or even better, move your entire app into a dedicated folder, open it as an RStudio Project, and deploy from there to ensure nothing gets left out.

3. Simulate the Shinyapps.io Environment Locally

  • Use rsconnect::runApp() instead of the regular runApp() to launch your app. This function mimics the runtime environment of shinyapps.io, so it might reveal errors that don't show up in your local RStudio session.
  • Set your working directory to your app's root folder before running the app:
    setwd("path/to/your/app/folder")
    runApp()
    
    Shinyapps.io runs your app from the project root, so this helps replicate any path-related issues.

4. Check Shinyapps.io Logs for Details

  • Log into your shinyapps.io account, navigate to your app, and click the "Logs" tab. The full error trace will often include more context—like a failed file read or missing package—that explains why BPT wasn't created. For example, if you see Error in read.csv: cannot open file 'BPT_data.csv': No such file or directory, you know the data file wasn't uploaded correctly.

5. Make BPT's Creation Explicit and Reproducible

  • Don't rely on BPT existing in your local R environment when deploying. Write the full code to create BPT directly in your app (e.g., in global.R). If BPT is a large object you don't want to regenerate every time, consider saving it as an .RData file with save(BPT, file = "BPT.RData"), then load it in global.R with load("BPT.RData")—just make sure the .RData file is included in your deployment.

Give these steps a try, and you should be able to track down why BPT isn't being found on shinyapps.io.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.26 08:37:00