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

pins doesnt seem to work with rocker / docker #812

Closed
ncullen93 opened this issue Nov 20, 2023 · 3 comments
Closed

pins doesnt seem to work with rocker / docker #812

ncullen93 opened this issue Nov 20, 2023 · 3 comments

Comments

@ncullen93
Copy link

I am using rocker/verse in my docker file and when I try to load pins, it gives me the same error from #705

Error: package or namespace load failed for ‘pins’:
 .onLoad failed in loadNamespace() for 'pins', details:
  call: NULL
  error: [ENOENT] Failed to make directory '//.cache/pins': no such file or directory
Execution halted

I looked further and believe the error is from this function:

board_cache_path <- function(name) {
  # R_CONFIG_ACTIVE suggests we're in a production environment
  if (has_envvars("R_CONFIG_ACTIVE") || has_envvars("PINS_USE_CACHE")) {
    path <- fs::dir_create(tempdir(), "pins")
  } else if (has_envvars("PINS_CACHE_DIR") ) {
    path <- Sys.getenv("PINS_CACHE_DIR")
  } else {
    path <- cache_dir()
  }
  fs::path(path, name)
}

I guess rocker doesnt set R_CONFIG_ACTIVE so pins doesnt know it's in a production environment? In any case, setting R_CONFIG_ACTIVE as an environment variable in my heroku app makes the error go away.

Hard to make a reprex but basically the same reprex suggested in #705 gives the error when deployed .

@juliasilge
Copy link
Member

Yes, it's true that the default mode for pins is set up for interactive work, and to use pins in an environment that is very limited in permissions or even read only, you need to set an environment variable to control the cache path. You can set R_CONFIG_ACTIVE like you found, or we document/recommend setting one of the environment variables that control where the pins cache is. For example from R, before loading the pins library, you could do something like:

Sys.setenv(PINS_CACHE_DIR = base::tempdir())
Sys.getenv("PINS_CACHE_DIR")
#> [1] "/var/folders/hv/hzsmmyk9393_m7q3nscx1slc0000gn/T//RtmpIFoEAQ"

Created on 2023-11-20 with reprex v2.0.2

Then you'd just have a per-session cache that writes to the temp directory only.

@ncullen93
Copy link
Author

Thanks!!

Copy link

github-actions bot commented Dec 5, 2023

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants