posit-dev / posit-dev/py-shiny
include_css tmp-folder cannot be shared by multiple users
@gshotwell is already working on this.
Since Oct 12, 2023.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
Hi,
When working on the same machine on the same project with multiple colleagues, we run into an issue with the following stripped-down example:
from shiny import App, ui
app_ui = ui.page_fluid(ui.head_content(ui.include_css("path_to_file.css")))
def server(input, output, session):
...
app = App(app_ui, server)
For the first user, the app runs perfectly fine. The second user runs into a PermissionError, because he cannot access the /tmp/shiny_include_files folder.
(venv) $ shiny run app.py
Traceback (most recent call last):
File "/home/<user>/<project>/venv/bin/shiny", line 8, in <module>
sys.exit(main())
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/click/core.py", line 1157, in __call__
return self.main(*args, **kwargs)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/click/core.py", line 1078, in main
rv = self.invoke(ctx)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/click/core.py", line 1688, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/click/core.py", line 1434, in invoke return ctx.invoke(self.callback, **ctx.params)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/click/core.py", line 783, in invoke
return __callback(*args, **kwargs)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/shiny/_main.py", line 140, in run
return run_app(
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/shiny/_main.py", line 285, in run_app
uvicorn.run( # pyright: ignore[reportUnknownMemberType]
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/uvicorn/main.py", line 587, in run
server.run()
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/uvicorn/server.py", line 61, in run
return asyncio.run(self.serve(sockets=sockets))
File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/uvicorn/server.py", line 68, in serve
config.load()
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/uvicorn/config.py", line 467, in load
self.loaded_app = import_from_string(self.app)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/uvicorn/importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/<user>/<project>/app.py", line 30, in <module>
ui.include_css("./www/stylesheet.css"),
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/shiny/ui/_include_helpers.py", line 165, in include_css
path_dest, hash = maybe_copy_files(file_path, include_files)
File "/home/<user>/<project>/venv/lib/python3.8/site-packages/shiny/ui/_include_helpers.py", line 228, in maybe_copy_files
os.makedirs(tmpdir, exist_ok=True)
File "/usr/lib/python3.8/os.py", line 223, in makedirs
mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/tmp/shiny_include_files/5e31f6ddb9b46e58cac90a3d43cda48e0e'
A work around is to not include_css the file, but to link to it directly (i.e. ui.tags.link(href="path_to_file.css", rel="stylesheet")), but that defies the purpose of the include_css function.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.