Working around Mac OS X Catalina's restrictions?
This isn't precisely a wing issue, but I'm running into it in wing specifically, so I'm hoping you guys might have an answer. I recently updated my mac OS machine to Catalina (BIG mistake!). Now trying to run commands like os.listdir or anything else that accesses the file system from the wing debugger or built-in shell just gives a "permission denied" error - even though I am just trying to access my files. I have tried adding WingPro.app and wing-internal-python to the "full disk access" section of the security preferences pane, but I still get the issue. Running python through the terminal, on the other hand, works fine after adding terminal to that section. So it seems like I should be able to fix this by adding something to the full disk access section, but I can't figure out what... Any tips/ideas? Thanks.
EDIT: PRECISE steps to recreate this issue:
- Add WingPro.app to the full disk access list in the security pane. Make sure it is NOT listed in the "Files and Folders" section
- Open WingPro, but DO NOT open or create any documents in Documents, Desktop, etc.
- From the python shell, try to run something like os.listdir() on your Documents, Desktop, etc
As an interesting note, this issue is "fixed" the first time WingPro itself tries to access (open or save) a file in any of the affected directories. Once that has happened, even if only once, this problem no longer exists. Even removing Wing from the Full disk access section (with wing not running) does not cause the issue to re-appear. Also, apparently, this problem does not arise if you do not first add Wing to the full disk access section, as in that situation the system properly prompts to allow access (according to comments).
This is clearly an issue with the implementation of the new security features in Catalina, and how they interact with the existing "full disk access" permissions, and not an issue with WingIDE. In any case, now that WingPro has accessed documents in all relevant locations, it is working properly. Thanks for the feedback!
Comments
Does it work to add the Python you are running to the list? You can see where that is with 'print(sys.executable)' after 'import sys'. Catalina does seem to be causing a lot of problems, and I think this may be a new one we've not yet seen.
Interesting wrinkle. So sys.executable points to python in my virtualenv (well, venv technically), which is a symlink to /Library/Frameworks/Python.framework/Versions/3.6/bin/python3, which is itself a symlink to python3.6 in the same directory - which is not recognized as a executable by the security preferences pane (it is disabled from selection and has a document icon). Looking at it in terminal, and comparing to other things in the same directory that are recognized as executables, the only difference I can see is that the python binary is owned by root, while the ones that are recognized are owned by me...
What are the full versions of Wing, Python, and macOS that you're using?
I'm having difficulty reproducing this with Wing 7.1.3.1, Python 3.6.4, and macOS 10.15.2 using os.listdir('/Users/<username>/Documents') as a test after giving Wing permission to use the Documents folder. I also wrote a file in Documents without a problem. I tried Python 3.6.4 just because it's an older version that predates Catalina's release.
Wing 7.1.3.1, MacOS 10.15.2, python 3.6.5. I think the key here is this line: "...after giving Wing permission to use the Documents folder" How on earth do you do that???? Cause just giving it full disk access doesn't seem to be enough...at least, not for me. Unless that is what you were referring to?
Interestingly, running sys.executable from the terminal python (which does work) and from the Wing python shell (which gives the error) can return the exact same result, so it's not the python executable itself that is different. If you remove wing from having permission to use the Documents folder, do you get the PermissionError? If so, there has to be something different about how you are giving wing permission to use the documents folder and how I am...