Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I access hidden system files with R?

Tags:

macos

r

sandbox

I am Mac User. Whenever I want to access Mail folder located in the /Users/user_name/Library/Mail folder; RStudio just ignores it and doesn't show any files.

setwd("/Users/user_name/Library/Mail")`

list.dirs("/Users/user_name/Library/Mail")
> character(0)

list.files("/Users/user_name/Library/Mail")
> character(0)

I understand that because of access to these files requires admin authorization, the R cannot access them. Is there a way to grant admin access to R to access hidden system files?

This question is cross-posted on RStudio Community forum two days ago. Unfortunately, I couldn't get a reply. That's why I asked here again.

Edit: Both of list.files() and list.dirs() return nothing.

like image 793
Can H. Avatar asked Oct 16 '22 10:10

Can H.


1 Answers

Add both the R executable and RStudio executable (drag their icons) to the Full Disk Access element under the Privacy tab of System Preferences => Security & Privacy:

enter image description here

NOTE: I also have R and Rscript in there but the pane is too small to show them.

Also NOTE that I do see

nw_path_close_fd Failed to close guarded necp fd 22 [9: Bad file descriptor]

in the Console.app on these attempts and my call to list.dirs() appears to hang but it's just taking a while b/c I have a ton of folders/files under there (thanks, gmail).

I'd try it incrementally with recursive=FALSE in list.dirs() until you've verified everything is working.

This post has some links that provide background on this new sandboxed filesystem behaviour.

like image 194
hrbrmstr Avatar answered Oct 20 '22 17:10

hrbrmstr