Removing Addon with compiled modules(e.g. cython) on Windows will cause PermissionError: [WinError 5] Access is denied #77837
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
12 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#77837
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Linux-4.15.0-101-generic-x86_64-with-debian-buster-sid 64 Bits
Graphics card: GeForce GTX 1050/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 435.21
Blender Version
Broken: version: 2.83.0, branch: master, commit date: 2020-06-03 14:38, hash:
211b6c29f7
Short description of error
Any addon with complied modules can't be properly removed on Windows using
bpy.ops.preferences.addon_remove()
This error will pop up:
Exact steps for others to reproduce the error
utils/print.py[d]
)MACHIN3: Printer
from the operator search menu, then take look at the terminalRemoveAddonException.zip
Thoughts
Addon removal is done in
/opt/blender 2.83/2.83/scripts/startup/bl_operators/userpref.py
, specifically inclass PREFERENCES_OT_addon_remove()
.in line 776, it's doing this:
shutil.rmtree(path)
shutil.rmtree() takes two optional arguments:
ignore_errors
onerror
If
ignore_errors
were to be set toTrue
, the addon removal would finish without the exception, which in my view would be preferable to the current implementation.It won't completely remove the addon folder however, as the compiled module will remain in the addon's folder.
Using
onerror
a custom function can be passed in to deal with the problem. It turns out, that while python doesn't like the module to be removed on Windows, it doesn't mind it being moved elsewhere. So what could be done is this:In this example. the file is moved to a trash folder in the scripts users resources, so parallel to the addons folder.
Doing this Blender is able to completely remove the addon folder.
Perhaps, Blender could then also remove that trash folder when closing, or the next time it starts and before any addons are registered?
IMO, at the very least,
shutil.rmtree()
should use theignore_errors
argument.The best solution would be to have python release the module somehow, but based on my research, that's not possible? Any input is appreciated.
References (aka other people having this issue)
Added subscriber: @MACHIN3
Removing Addon with compiled modules(ex. cython) on WIndows will cause PermissionError: [WinError 5] Access is denied:to Removing Addon with compiled modules(e.g. cython) on WIndows will cause PermissionError: [WinError 5] Access is denied:Removing Addon with compiled modules(e.g. cython) on WIndows will cause PermissionError: [WinError 5] Access is denied:to Removing Addon with compiled modules(e.g. cython) on Windows will cause PermissionError: [WinError 5] Access is deniedAdded subscriber: @rlguy
This issue also affects the FLIP Fluids addon and is a common error when our users try to uninstall our addon. If there is a solution or workaround to to this issue, it would be greatly appreciated!
Added subscriber: @LazyDodo
Changed status from 'Needs Triage' to: 'Archived'
There's not a whole lot we can do about this from the blender side, i took a quick peek at the python source and they just seem to lack any kind of management that would allow you to do this.
you may be able to forcefully unload the library with ctypes and forcefully calling FreeLibrary a few times in a row, but that'll be pretty far off the supported path for both blender and python and could blow up in your face given python may not enjoy the dll being gone at shutdown time, you may have more control over this in a pure ctypes based solution (rather than a python module solution)
either way, not a bug we can fix in blender, so by the tracker rules i'll have to close this ticket.
Why not at least prevent the error using the
ignore_errors
arg?Changed status from 'Archived' to: 'Needs Triage'
Sorry, overlooked that bit, i'll leave that for the python guys to decide, for unloading the library there is really nothing we can do.
Added subscriber: @bent
Added subscriber: @EAW
I notice that your uninstall instructions don't tell users to first disable the addon, restart, and then click remove. That is how I workaround this issue myself.
This is what Animation Nodes tells the user aswell. Not really fond of it though, I wish Blender had a more user friendly and / or unified way of doing it.
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @mano-wii
Added subscriber: @piiichan
Added subscriber: @BrianSavery
Also adding this being an issue with Radeon ProRender addon (only windows). I've tried forcefully unloading DLL but so far unsuccessfully.
Added subscriber: @timodriaan
Added subscriber: @regcs
This comment was removed by @regcs
I submitted a patch (D13685), which follows the suggestion by @MACHIN3:
/scripts/addons_trash/
NOTE:
Some specific python modules still may need to be unloaded manually in the add-on's
unregister()
call. I noticed that, e.g., thelogging
module demands alogging.shutdown()
.Added subscriber: @Zeastin
Added subscriber: @ArmoredWolf
Adding a ping here as D13685 was archived. @regcs were you able to or anyone else able to get a fix in?