Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle missing file access permissions more gracefully? #78

Open
Dragorn421 opened this issue Sep 17, 2021 · 1 comment
Open

Handle missing file access permissions more gracefully? #78

Dragorn421 opened this issue Sep 17, 2021 · 1 comment
Labels

Comments

@Dragorn421
Copy link
Contributor

Dragorn421 commented Sep 17, 2021

When an addon is mistakenly installed under a Blender installation folder which happens to be under C:\Program Files\, the updater addon will eventually raise an error during registering due to not having write access to the filesystem there

I'm using an old version of the updater addon but looking at current code this is probably still relevant. Sorry if it got addressed and I should just bother updating, lazy me

Here's the trace

io_export_objex2 updater verbose is enabled
Exception in module register(): C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\__init__.py
Traceback (most recent call last):
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\modules\addon_utils.py", line 382, in enable
    mod.register()
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\__init__.py", line 564, in register
    addon_updater_ops.register(bl_info)
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\addon_updater_ops.py", line 1509, in register
    showReloadPopup()
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\addon_updater_ops.py", line 835, in showReloadPopup
    saved_state = updater.json
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\addon_updater.py", line 298, in json
    self.set_updater_json()
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_export_objex2\addon_updater.py", line 1467, in set_updater_json
    os.makedirs(self._updater_path)
  File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\python\lib\os.py", line 223, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'C:\\Program Files\\Blender Foundation\\Blender 2.91\\2.91\\scripts\\addons\\io_export_objex2\\io_export_objex2_updater'

Since this halts the registering, the addon doesn't unregister either and further registering attempts (eg by the user clicking the "enable addon" checkbox again) raise misleading errors about already-registered classes.

I think it would be nice to have the autoupdater handle "no file write permission" more gracefully. Maybe it should just disable itself and draw a message about "installed in the wrong directory, don't have write permissions" in the addon properties where the updater properties would be?

I can take care of PRing the necessary changes, I just want to find what the best way to handle this is first

@TheDuckCow TheDuckCow added the bug label Sep 18, 2021
@TheDuckCow
Copy link
Collaborator

Thanks a ton for sharing this issue edge case! We for sure don't want to break registration, appreciate all the details here - and a thousand times more if you're willing to do the PR! I'd be happy to review and give guidance if unsure where to start, but you should be able to make use of the error and error_msg fields for some of this, and also detecting if this is set within the draw window before drawing anything else.

I think it would be good to make sure there are stdout printouts, as well as a default label drawn in preferences in place of the rest of the UI indicating as you say, "Updater has no write permissions." with maybe some subtext for: "Try running blender as admin." Not sure if there's a nicely succinct way of describing "If you installed into the blender core addons folder, try installing to the user folder", as that could be wordy and just cause more confusion.

The other thing we should likely try to do in that state is still offer the "manual download" option, which is a button that just opens the according releases page, so it's still at least somewhat useful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants