r-lib / styler

Non-invasive pretty printing of R code
https://styler.r-lib.org
Other
725 stars 71 forks source link

New cache issues after submission of 1.10.2 #1146

Closed lorenzwalthert closed 1 year ago

lorenzwalthert commented 1 year ago

Dear maintainer,

package styler_1.10.2.tar.gz has been auto-processed. The auto-check found problems when checking the first order strong reverse dependencies. Please reply-all and explain: Is this expected or do you need to fix anything in your package? If expected, have all maintainers of affected packages been informed well in advance? Are there false positives in our results?

Changes to worse in reverse dependencies Debian: https://win-builder.r-project.org/incoming_pretest/styler_1.10.2_20230827_141256/reverseDependencies/summary.txt ShinyQuickStarter, shinymeta

Log dir: https://win-builder.r-project.org/incoming_pretest/styler_1.10.2_20230827_141256/ The files will be removed after roughly 7 days.

Pretests: Windows: https://win-builder.r-project.org/incoming_pretest/styler_1.10.2_20230827_141256/Windows/00check.log Debian: https://win-builder.r-project.org/incoming_pretest/styler_1.10.2_20230827_141256/Debian/00check.log

Last published version on CRAN:

CRAN Web: https://cran.r-project.org/package=styler

Best regards, CRAN teams' auto-check service Package check result: OK

Changes to worse in reverse depends:

Package: shinymeta Check: whether the package can be unloaded cleanly New result: WARNING Error: package or namespace load failed for ‘shinymeta’: .onLoad failed in loadNamespace() for ‘styler’, details: call: getWritablePathname.Arguments(static, file = "dummy-not-created", error: No write permission for directory: /tmp/check-CRAN-incoming-hornik/cache/R/R.cache/styler In addition: Warning message: In fileAccess.default(pathT, mode = 2) : file.access(..., mode=2) and file(..., open="ab") gives different results (0 != -1). Will use the file() results: /tmp/check-CRAN-incoming-hornik/cache/R/R.cache/styler/u Execution halted

Package: ShinyQuickStarter Check: whether package can be installed New result: ERROR Installation failed.

lorenzwalthert commented 1 year ago

I can reproduce a similar issue:

  1. Have local directory structure "~/Library/Caches/org.R-project.R/R/R.cache/styler".
  2. mark that directory read only (chmod u-w ~/Library/Caches/org.R-project.R/R/R.cache/styler).
  3. (re)start R and run R.cache::getCachePath("styler")
[2023-08-27 22:06:13.004685] Exception: No write permission for directory: /Users/lorenz/Library/Caches/org.R-project.R/R/R.cache/styler

at #13. getWritablePathname.Arguments(static, file = "dummy-not-created", 
              path = path, ...)
          - getWritablePathname.Arguments() is in environment 'R.utils'

  at #12. getWritablePathname(static, file = "dummy-not-created", path = path, 
              ...)
          - getWritablePathname() is in environment 'R.utils'

  at #11. getWritablePath.Arguments(static, ...)
          - getWritablePath.Arguments() is in environment 'R.utils'

  at #10. getWritablePath(static, ...)
          - getWritablePath() is in environment 'R.utils'
          - originating from '<text>'

  at #09. Arguments$getWritablePath(path)
          - Arguments$getWritablePath() is local of the calling function

  at #08. getCachePath.default("styler")
          - getCachePath.default() is local of the calling function

  at #07. R.cache::getCachePath("styler")
          - R.cache::getCachePath() is in environment 'R.cache'

  at #06. list.dirs(R.cache::getCachePath("styler"), recursive = FALSE)
          - list.dirs() is in environment 'base'
          - originating from '/Users/lorenz/git/styler/R/zzz.R'

  at #05. remove_cache_old_versions()
          - remove_cache_old_versions() is in environment 'styler'
          - originating from '/Users/lorenz/git/styler/R/zzz.R'

  at #04. nsenv[[f_name]](dirname(ns_path), package)
          - nsenv[[f_name]]() is in environment 'styler'

  at #03. run_pkg_hook(package, "load")
          - run_pkg_hook() is in environment 'pkgload'

  at #02. pkgload::load_all(path = path, reset = reset, recompile = recompile, 
              export_all = export_all, helpers = helpers, quiet = quiet, 
              ...)
          - pkgload::load_all() is in environment 'pkgload'

  at #01. devtools::load_all(".")
          - devtools::load_all() is in environment 'devtools'

Error: No write permission for directory: /Users/lorenz/Library/Caches/org.R-project.R/R/R.cache/styler
> 

This call gets triggered in styler:::.onLoad() -> remove_cache_old_versions().

lorenzwalthert commented 1 year ago
  1. I think {R.cache} should not return an error in that case but construct a path to a temporary cache that is writable.
  2. The problem occurs on CRAN because {shinymeta}'s .onLoad() triggers {styler}'s .onLoad(). Since {shinymeta} does not actually style any code later, the cache does not need to be writable and we can just rlang::try_fetch() the error in .onLoad() and hopefully make pre-tests work.
  3. I don't understand why the cache root on CRAN (/tmp/check-CRAN-incoming-hornik/cache/R/R.cache/styler) is not writable. Making this writable would probably solve the problem, but I doubt that Hornik is going to change his local (?!) setup.
lorenzwalthert commented 1 year ago

Close with release 1.10.2