Skip to content

Extrernal resource cannot be found without addResourcePath() although it's part of www\ #4366

Description

@FBrockmeyer

System Details

Tried different browsers.

> sessionInfo()
R version 4.5.2 (2025-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 24.04.4 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
 [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
 [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
 [9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: Etc/UTC
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] shiny_1.13.0

loaded via a namespace (and not attached):
 [1] igraph_2.2.2      digest_0.6.39     later_1.4.7       R6_2.6.1         
 [5] httpuv_1.6.16     fastmap_1.2.0     magrittr_2.0.4    cachem_1.1.0     
 [9] pkgconfig_2.0.3   htmltools_0.5.9   lifecycle_1.0.5   promises_1.5.0   
[13] cli_3.6.5         xtable_1.8-8      visNetwork_2.1.4  compiler_4.5.2   
[17] rstudioapi_0.18.0 tools_4.5.2       mime_0.13         Rcpp_1.1.1       
[21] otel_0.2.0        jsonlite_2.0.0    htmlwidgets_1.6.4 rlang_1.1.7      
[25] box_1.2.1     

Project's Structure

project/
|-- notebooks/
    |-- .... 
|   `-- README.Rmd
|-- www/
|   |-- logo.png
|   |-- header.html
|   `-- styles.css
|-- shiny/
    |-- R/
        |-- server.R
        |-- ui.R
        `-- mods/ 
    `-- library/
|-- app.R
`-- README.md 

File Details

header.html looks like

<header>
  <h1 class="header-title">blah</h1>
  <img src=www/logo.png alt="blah-Logo" class="header-logo">
</header>

while ui.R is similar to

# Module Management -------------------------------------------------------
box::use(
  shiny[fluidPage, includeHTML, includeCSS, addResourcePath, tags], # not adapted
  <...>
  )

# User Interface ----------------------------------------------------------------
#' @export
ui = function() {
  fluidPage(
    title = 'blah',
    # shiny deploys from app.R root (project)
    includeHTML('www/header.html'), 
   <...>
   )
}

and app.R is somewhat irregular

# Module Management ----------------------------------------------------
box::use(
  shiny[shinyApp, runApp],
  ./shiny/R/server, 
  ./shiny/R/ui
  ) 


# ENTRYPOINT --------------------------------------------------------------
shinyApp(
  ui = ui$ui,
  server = server$server,
  options = list(
      <...> 
    )
  ) |> 
  runApp()

Problem Detail

When running the app, www/logo.png in www/header.html cannot be found. This doesn't change when deleting the www/-prefix. However, when adding addResourcePath(prefix = 'www', directoryPath = './www') above ui() in ui.R the logo gets displayed as expected (as long as the prefix is set). I do not understand where this is in line with addResourcePath() documentation. Same holds for the styles.css.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions