问题
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.
回答1:
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:
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.
来源:https://stackoverflow.com/questions/53223774/how-can-i-access-hidden-system-files-with-r