Skip to content

fix(static_assets): Need the directory containing the app.py, not the file itself #1219

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2024

Conversation

gadenbuie
Copy link
Collaborator

@gadenbuie gadenbuie commented Mar 13, 2024

Currently if you set

app = App(app_ui, server, static_assets="www")

you'll get a helpful error message with two recommendations

ValueError: static_assets must be an absolute path: "www". Consider using one of the following instead:
  os.path.join(__file__, "www")  OR  pathlib.Path(__file__).parent/"www"

Unfortunately, the first option isn't quite right

os.path.join(__file__, "www")

and will try to mount /Users/person/path/to/app/app.py/www instead of /Users/person/path/to/app/www.

The fix is to use

os.path.join(os.path.dirname(__file__), "www")

@gadenbuie gadenbuie requested a review from wch March 13, 2024 20:57
Copy link
Collaborator

@wch wch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@wch wch merged commit 4a7dc8d into main Mar 16, 2024
@wch wch deleted the fix/static-assets-advice branch March 16, 2024 02:11
schloerke added a commit to joesho112358/py-shiny that referenced this pull request Mar 23, 2024
* main: (24 commits)
  chore: Disable broken test on CI; Fix broken docs entries (posit-dev#1241)
  Add back missing session methods (posit-dev#1239)
  Add kitchensink tests for valuebox (posit-dev#1229)
  For Express, emit message if need to upgrade rsconnect-python (posit-dev#1233)
  feat: Editable data frame (posit-dev#1198)
  Add tests for shiny_mode comment detection
  fix(input_dark_mode): Allow users to customize `style` attribute (posit-dev#1207)
  chore(get_current_session): Return default session if current is explicitly None (posit-dev#1086)
  chore: use dev htmtlools (posit-dev#1228)
  feat(layout_columns): Use `sm` as the default `col_widths` breakpoint (posit-dev#1222)
  feat: ensure min/max height args on `value_box()` and column layouts (posit-dev#1223)
  fix(static_assets): Need the directory containing the `app.py`, not the file itself (posit-dev#1219)
  Update bslib and shiny dependencies (posit-dev#1221)
  Update docstring and give hint for mypy
  Add support for Shiny Express in Quarto Dashboards, take 2 (posit-dev#1217)
  Force UTF-8 for Shiny Express on Windows (posit-dev#1203)
  Typing fixes
  feat(card): Report full screen state as a Shiny input (posit-dev#1215)
  Use TypeScript strict mode (posit-dev#1208)
  Update author email
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants