Skip to content
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

bslib dependencies fail during file copy when installed read-only #1154

Open
natashanath opened this issue Jan 6, 2025 · 3 comments
Open

Comments

@natashanath
Copy link

natashanath commented Jan 6, 2025

Permission denied when using precompiled css from a read-only bslib installation

In enterprise settings it is not uncommon to have a centralized library of packages where everything is installed read-only and maintained by designated users/teams. Another use case which is quickly gaining popularity is using Nix package manager for maintaining data science environments. Nix also installs everything read-only.

file.copy(precompiled_css, out_file)

One solution would be to add copy.mode = FALSE to the file.copy calls, so that the file mode attributes are not preserved.

This fails in applications that call bslib internally, like elmer

library(S7)
library(httr2)
library(coro)
library(shinychat)
library(elmer)

chat <- chat_ollama(
  model = 'zephyr7b',
  system_prompt = 'You are a friendly but terse coding assistant. You are an expert in R, Python, SQL.',
  echo = TRUE
)
elmer::live_browser(chat)
# UI error displayed:
An error occurred: inherits(pool, "curl_multi") is not TRUE
# Error in debugging:
Warning in file.copy(from, to, ...) :
  problem copying /path/to/R/library/bslib/lib/bs3/assets/fonts/bootstrap/glyphicons-halflings-regular.eot to /path/to/tmp/bslib-precompiled-5/fonts/bootstrap/glyphicons-halflings-regular.eot: Permission denied
Warning in file.copy(from, to, ...) :
  problem copying /path/to/R/library/bslib/lib/bs3/assets/fonts/bootstrap/glyphicons-halflings-regular.svg to /path/to/tmp/bslib-precompiled-5/fonts/bootstrap/glyphicons-halflings-regular.svg: Permission denied
Warning in file.copy(from, to, ...) :
  problem copying /path/to/R/librarybslib/lib/bs3/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf to /path/to/tmp/bslib-precompiled-5/fonts/bootstrap/glyphicons-halflings-regular.ttf: Permission denied
Warning in file.copy(from, to, ...) :
  problem copying /path/to/R/library/bslib/lib/bs3/assets/fonts/bootstrap/glyphicons-halflings-regular.woff to /path/to/tmp/bslib-precompiled-5/fonts/bootstrap/glyphicons-halflings-regular.woff: Permission denied
Warning in file.copy(from, to, ...) :
  problem copying /path/to/R/library/bslib/lib/bs3/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 to /path/to/tmp/bslib-precompiled-5/fonts/bootstrap/glyphicons-halflings-regular.woff2: Permission denied

Added here based on the issue raised on elmer

@gadenbuie
Copy link
Member

One solution would be to add copy.mode = FALSE to the file.copy calls, so that the file mode attributes are not preserved.

That seems reasonable, would you like to submit a PR with the fix?

@gadenbuie
Copy link
Member

Some follow up questions: Are you sure that the file mode attributes are the issue? Can you otherwise write files into R's temp folders on your system?

@gadenbuie
Copy link
Member

gadenbuie commented Jan 6, 2025

Part of my reservation is that the files causing the warning are not copied via file.copy() in the linked line but instead are copied by sass::write_file_attachments() below:

if (!is.null(precompiled_css)) {
out_dir <- file.path(tempdir(), paste0("bslib-precompiled-", version))
if (!dir.exists(out_dir)) {
dir.create(out_dir)
}
out_file <- file.path(out_dir, basename(precompiled_css))
file.copy(precompiled_css, out_file)
# Usually sass() would handle file_attachments and dependencies,
# but we need to do this manually
out_file <- attachDependencies(out_file, htmlDependencies(as_sass(theme)))
write_file_attachments(
as_sass_layer(theme)$file_attachments,
out_dir
)

I haven't looked into file.copy() internals either, but if the file mode attributes were an issue I'd expect the files to be copied but subsequent writes to fail. AFAIK we only read these files, so the warnings here smell different to me.

It might be worth explaining your system set up so that we can recreate the environment and reproduce the issue.

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

No branches or pull requests

2 participants