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

部署含自定义R包的Shiny应用至shinyapps.io遇错误求助

Fixing Shiny App Deployment with Custom GitHub Package on shinyapps.io

Let’s work through this step by step—your local setup works, so the issue is almost certainly how shinyapps.io is trying to install and access your NxT package. Here’s what to check and fix:

1. Verify Your GitHub Repository Structure

The error "Does not appear to be an R package (no DESCRIPTION)" tells us shinyapps.io can’t find your package’s core metadata file in your GitHub repo.

  • Double-check your GitHub repo: Open your repo at github.com/zertupo/NxT and confirm the DESCRIPTION file, NAMESPACE, and R/ folder are all in the root directory (not nested inside a subfolder like NxT/NxT/).
  • Test locally first: Run devtools::install_github("zertupo/NxT") on your machine. If this fails, fix your repo structure before trying to deploy again. If it works locally, the repo structure is correct, and we can move to the next step.

2. Declare Dependencies Properly (The Right Way)

shinyapps.io builds your app’s environment before launching it—running install_github() inside your server.R or ui.R runs too late (during app runtime, not build time). Instead, use one of these two reliable methods:

Create a DESCRIPTION file in your Shiny app’s root directory (separate from your package’s DESCRIPTION). This tells shinyapps.io exactly what dependencies to install during the build phase:

Package: MyShinyApp
Type: Shiny
Title: Your App Name
Version: 0.1.0
Authors@R: person("Aurélien", "your-email@example.com", role = c("aut", "cre"))
Description: Shiny app using the custom NxT package.
Depends: shiny
Imports: NxT
Remotes: zertupo/NxT

When you deploy, shinyapps.io will automatically pull and install NxT from GitHub, along with any dependencies listed in your package’s DESCRIPTION.

Method 2: Install in global.R (Backup Option)

If you prefer not to use a DESCRIPTION file, create a global.R in your app directory with this code to install the package during the build phase:

# Install devtools and NxT if missing
if (!requireNamespace("devtools", quietly = TRUE)) {
  install.packages("devtools")
}

if (!requireNamespace("NxT", quietly = TRUE)) {
  devtools::install_github("zertupo/NxT", dependencies = TRUE)
}

library(NxT)

This ensures the package is installed before your app’s server or ui code runs.

3. Re-Deploy and Check Logs

  • Use rsconnect::deployApp() (or the RStudio "Publish" button) to re-upload your app with the new setup.
  • If you still see errors, check the full logs in shinyapps.io: Go to your app’s dashboard, click "Logs", and look for detailed installation errors (like missing dependencies in your NxT package’s DESCRIPTION).

Quick Troubleshooting Checklist

  • Confirm your NxT package’s DESCRIPTION lists all its own dependencies (e.g., if it uses dplyr, add dplyr to Imports in the package’s DESCRIPTION).
  • Make sure your GitHub repo is public (shinyapps.io can’t access private repos without additional authentication).

内容的提问来源于stack exchange,提问作者Aurélien

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.28 04:01:27