conda / menuinst

Cross platform menu item installation
https://conda.github.io/menuinst/
BSD 3-Clause "New" or "Revised" License
36 stars 42 forks source link

PermissionsError when accessing some directories with os module #123

Closed jaimergp closed 1 year ago

jaimergp commented 1 year ago

This issue was fixed already, but I am adding a reference here for provenance and better tracking in the future. See https://github.com/napari/packaging/issues/38#issue-1428901699 for full discussion and resolution


🐛 Bug

A PermissionError is raised when using os.scandir with the conda-based application bundle. I've noticed the same issue with Spyder as well with conda-based application bundle.

This issue only manifests with the three user directories ~/Desktop, ~/Documents, and ~/Downloads (and anything therein). No other directories on the system produce the error.

Interestingly, this issue does not manifest when launching the application executable directly.

$ ~/Applications/napari\ \(0.4.16rc7\).app/Contents/MacOS/napari_\(0.4.16rc7\)

I've observed identical behavior on two separate machines:

To Reproduce

Steps to reproduce the behavior:

  1. Launch condo-based napari application bundle napari (0.4.16rc7).app from Finder
  2. View the iPython console
  3. Attempt os.scandir for any of the three user directories ~/Desktop, ~/Documents, or ~/Downloads
  4. Observe the error
In [1]: import os

In [2]: os.scandir('/Users/ryan/')
Out[2]: <posix.ScandirIterator at 0x179e18960>

In [3]: os.scandir('/Users/ryan/Documents/')
---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 os.scandir('/Users/ryan/Documents/')

PermissionError: [Errno 1] Operation not permitted: '/Users/ryan/Documents/'
/Users/ryan/Library/napari-0.4.16rc7/envs/napari-0.4.16rc7/lib/python3.9/site-packages/ipykernel/kernelbase.py:751: RuntimeWarning: coroutine 'InProcessKernel._abort_queues' was never awaited!

Environment

napari: 0.4.16rc7 Platform: macOS-12.5.1-x86_64-i386-64bit System: MacOS 12.5.1 Python: 3.9.13 | packaged by conda-forge | (main, May 27 2022, 17:00:52) [Clang 13.0.1 ] Qt: 5.15.3 PySide2: 5.15.4 NumPy: 1.22.4 SciPy: 1.8.1 Dask: 2022.05.2 VisPy: 0.9.6

OpenGL:

Screens:

Plugins: