I posted my question here already, but was wondering if the community have an answer.
I have a volume is called BOB and a data text file at /Volumes/BOB/datafolder/data.txt. When I want to set the directory to the volume, it works.
setwd("/Volumes/BOB/") # This works
However, when I use list.files() it tells me character(0), but I can clearly see in my Finder that there are folders here. In addition the command below don't work as expected.
setwd("/Volumes/BOB/datafolder/") # This reverts to $HOME or ~ and doesn't go to the folder...
So whenever I try to point to a dataset on a volume, it tells me that
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file '/Volumes/BOB/datafolder/data.txt': Operation not permitted
I tried putting a subset of the data on the main drive of the computer and it worked. However, the data is very large and can't put the full dataset on my main drive. Would be awesome to be able to read the data directly from the external hard drive.
What are the file permissions on the datafolder folder and the data.txt file? Is it possible that you are running RStudio under an account that does not have access permissions to them?
The external hard drive was formatted to be USB External Physical Volume • Mac OS Extended (Journaled) on Mac. But again, the list.files()returns nothing. But the file is really there.
If you run Sys.info() in the RStudio console, does either the "user" or "effective_user" entry match "USER"? If not, are they in the "wheel" user group on your Mac?
'user' and 'effective_user' are the same and they match echo $USER. Also, there is no 'wheel' user group. Actually, I just tried putting the data on another external volume and it worked. I really don't know why the other drive doesn't want to be recognized by RStudio...
OK, I might have solved it. We'll see how it going to work in the future. Basically, when trying the data on another hard drive, I noticed that macOS was asking me to grant access to RStudio the new hard drive.
It got me thinking, from the suggestion you made, that there was a problem with the privacy or accessibility of the drive. So I went in System Settings -> Privacy & Security -> RStudio. Then under Removable Volumes I switched it off (Restarted RStudio) and then on again (Restarted RStudio). Then I had access to the files!
Hopefully this was the fix. Although it's not clear to me why it was doing this thing...