r-lib / styler

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

No write permission ~/.cache/R/R.cache/styler #1099

Closed vvarik closed 1 year ago

vvarik commented 1 year ago

On Linux, trying to install styler fails with: Error: package or namespace load failed for ‘styler’: .onLoad failed in loadNamespace() for 'styler', details: call: getWritablePathname.Arguments(static, file = "dummy-not-created", error: No write permission for directory: /home/varik/.cache/R/R.cache/styler

Sure enough: ~/.../R/R.cache$ ls -l drwxr-xr-x 3 root root 4096 Oct 18 2021 styler -rw-r--r-- 1 root root 431 Jun 8 2021 README.txt

Any other packages install fine.


Ubuntu 20.04.6, R 4.2.3

lorenzwalthert commented 1 year ago

Can you install {R.cache}? Because that function trace is from it.

vvarik commented 1 year ago

Yes, could install R.cache without any problems. Tried to install styler after that, same 'no write permission' issue. Tried to load first R.cache and install then styler, same issue.

lorenzwalthert commented 1 year ago

Also see https://github.com/r-lib/styler/issues/871 and links there. I think you might have a non-standard permission setup here. Who owns the directory? The user? If not, maybe just create that directory manually?

vvarik commented 1 year ago

Alright, as suggested in #871, overriding R folder permissions fixed the problem:

cd ~/.cache sudo chown -R <username> R

I might have inadvertently created root owned R folder in ~/.cache/ a while ago -- there is plenty of confusion online about whether Linux users should install R packages with sudo or not (the answer is not, but I did not know any better initially).