29

I'm using Visual Studio Code with the C/C++ official extension from Microsoft to write C programs, running under macOS Catalina 10.15.3. The project folder lies in a path within the Documents folder on my home directory.

Every time I try to debug my code, a confirmation window pops up with the message "<program>" would like to access files in your Documents folder. I have to click the OK button to proceed.

This slow downs my workflow, and is cluttering the list of allowed apps inside System Preferences => Security & Privacy => Privacy => Files and Folders (which, strangely, won't let me delete files from the list -- I'll ask a question about this in Ask Different later, but that's not the main issue: I want to get rid of this confirmation window altogether.)

Is there a way to go straight to a debug session without having to click OK on this message every time?

There's an issue in the C/C++ extension's GitHub issue tracker apparently about the same problem, and the suggested solution is to grant access to Terminal. However, this doesn't fix the issue for me -- in fact, access to the Documents folder was already granted to Terminal a long time ago since I use Terminal daily.

swineone
  • 2,296
  • 1
  • 18
  • 32

5 Answers5

22

I've search high and low for a good solution to this that allows me to keep my project folders on my Desktop but haven't found anything. Apparently the Desktop, Documents, and Downloads files are just more strict now. I'm thinking macOS just thinks any change to a file that tries to access other files in these three folders is potentially nefarious and they try to play gatekeeper. It was obviously done as part of their security updates in moving towards tighter security but this is just such an unnecessary hiccup for developers.

Anyway, the only two solutions I've seen that work (I'm using Xcode, personally) is to move folders outside of the three folders I named earlier, or just run directly through the Terminal app rather than through an IDE. This obviously isn't perfect, but it works. I don't like not having my important projects on my Desktop anymore but until I find a better solution I guess that's what I'll do.

tanto_
  • 344
  • 2
  • 8
  • FWIW: Desktop, Documents, and Downloads tend to be synced with iCloud. And similar to how it's not best practice to commit output binaries to version control systems, I also don't like to upload to cloud storages either (which also tend to do versioning). As an aside, it's kind of unfortunate that GitHub Desktop defaults to using the Documents folder on Mac, but it's probably best to just avoid these directories for development. – Nicholas Miller Jul 18 '23 at 21:36
2

Grant Full Disk Access to the app you are building. This will make the pop-up disappear.

System Preferences > Security & Privacy > Privacy > Full Disk Access

rgos
  • 49
  • 5
  • 2
    Please add more details on how to grant the app. – Amir Fo Dec 30 '21 at 13:33
  • 1
    This doesn't work if you are running/executing something from VS code, it would require additional permission for the executable that VS code runs in order to accomplish the task. For e.g. if you are running a C++ file it would still ask for permission and the dialog box will appear. – Shaswat Lenka Aug 31 '22 at 10:29
  • 1
    Confirmed: this no longer seems to work on Monterey 12.5 and VS Code 1.74.00 – rgos Dec 09 '22 at 22:14
  • Also confirmed: moving your dev folder out of the Documents folder gets rid of the pop-up. See: https://stackoverflow.com/questions/69772354/helloworld-c-mysterious-request-to-access-desktop-folder – rgos Dec 10 '22 at 10:15
1

I don't know about your set up but I had the same issue. For me it was just a simple discrete permissions issue on my working directory.

chown -R <user>:everyone ~/Documents/C

Right click Finder / Documents / C and "get info" make sure your group has whatever permissions you want to give it.

enter image description here

Now my ctrl+shift+B builds without prompting. You might also want to remove any binaries you've allowed via prompt from System Preferences / Security and Privacy / Privacy / Files and Folders.

b0bu
  • 1,062
  • 1
  • 9
  • 24
1

Worked for me on macOS 12.6.

System Preferences -> Security & Privacy -> Privacy (Tab) -> Full Disk Access -> Xcode.app (or other app)

Check box must be selected for an app to get rid of """ would like to access files in your Documents folder" warning.

enter image description here

Ramis
  • 13,985
  • 7
  • 81
  • 100
  • 3
    This didn't work MacOS 13.1. I granted full disk access and the pop-up "...would like to access files in your Documents folder" still come up every time – Mote Zart Jan 25 '23 at 00:25
0

Under System Preferences > Security & Privacy > Privacy ("tab") you will see, on the left:

  • Files and Folders
    • This is where macOS has been keeping track of your responses to these silly "would like to access" notifications. Hit the unlock icon at the bottom left of the window, put in your passphrase to authenticate, and clean up this list with the +/- buttons as desired.
  • Full Disk Access
    • This is where you can list particular apps for which you never ever want to see these silly "would like to access" notifications for. For example I hit the plus button and added iTerm here, because I'll use that all over my system.
Jan Kyu Peblik
  • 1,435
  • 14
  • 20