Loading previous settings doesn't copy symlinks correctly #88670

Closed
opened 2021-05-29 18:13:11 +02:00 by Shinsuke Irie · 4 comments
Member

System Information
Operating system: Linux-5.11.0-17-generic-x86_64-with-glibc2.33 64 Bits
Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.73.01

Blender Version
Broken: version: 2.93.0 Beta, branch: master, commit date: 2021-05-28 16:16, hash: c369382977
Worked: version 2.92.0
Short description of error
When starting Blender first time after upgrading, copying user preferences from previous version goes wrong if there are symlinks in the user preference directory.

The symlinks in the source directory are expected to be symlinks also in the new directory, but actually the contents of the linked files are copied.
Furthermore, if the file pointed by the symlink doesn’t exist, an exception will be raised during copying.

Exact steps for others to reproduce the error

  1. Delete 2.93 user preference directory
$ cd ~/.config/blender
$ rm -rf 2.93
  1. In 2.92 user preference directory, create a symlink
$ cd ~/.config/blender/2.92/scripts/addons
$ ln -s PATH-TO-SOME-ADDON .
  1. Start Blender 2.93 and click "Load 2.92 Settings" button
    If the file the symlink points to doesn't exist, we should get an error like below:
Python: Traceback (most recent call last):
  File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/scripts/startup/bl_operators/userpref.py", line 147, in execute
    shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True)
  File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/python/lib/python3.9/shutil.py", line 557, in copytree
    return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks,
  File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/python/lib/python3.9/shutil.py", line 513, in _copytree
    raise Error(errors)
shutil.Error: [('/home/irie/.config/blender/2.92/scripts/addons/manuelbastionilab', '/home/irie/.config/blender/2.93/scripts/addons/manuelbastionilab', "[Errno 2] No such file or directory: '/home/irie/.config/blender/2.92/scripts/addons/manuelbastionilab'")]

location: <unknown location>:-1

shutil.copytree() in userpref.py seems to need an optional argmuent symlinks=True, which has been removed in 216291ddb3 though I'm not sure why @brecht removed it.
I confirmed the following patch resolves the issue:

diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py
index 3969386bad7..dd84dfa2df8 100644
--- a/release/scripts/startup/bl_operators/userpref.py
+++ b/release/scripts/startup/bl_operators/userpref.py
@@ -153,7 +153,7 @@ class PREFERENCES_OT_copy_prev(Operator):
 
     def execute(self, _context):
         import shutil
-        shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True)
+        shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True, symlinks=True)
 
         # reload preferences and recent-files.txt
         bpy.ops.wm.read_userpref()
**System Information** Operating system: Linux-5.11.0-17-generic-x86_64-with-glibc2.33 64 Bits Graphics card: GeForce GTX 1070/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 460.73.01 **Blender Version** Broken: version: 2.93.0 Beta, branch: master, commit date: 2021-05-28 16:16, hash: `c369382977` Worked: version 2.92.0 **Short description of error** When starting Blender first time after upgrading, copying user preferences from previous version goes wrong if there are symlinks in the user preference directory. The symlinks in the source directory are expected to be symlinks also in the new directory, but actually the contents of the linked files are copied. Furthermore, if the file pointed by the symlink doesn’t exist, an exception will be raised during copying. **Exact steps for others to reproduce the error** 1. Delete 2.93 user preference directory ``` $ cd ~/.config/blender $ rm -rf 2.93 ``` 2. In 2.92 user preference directory, create a symlink ``` $ cd ~/.config/blender/2.92/scripts/addons $ ln -s PATH-TO-SOME-ADDON . ``` 3. Start Blender 2.93 and click "Load 2.92 Settings" button If the file the symlink points to doesn't exist, we should get an error like below: ``` Python: Traceback (most recent call last): File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/scripts/startup/bl_operators/userpref.py", line 147, in execute shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True) File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/python/lib/python3.9/shutil.py", line 557, in copytree return _copytree(entries=entries, src=src, dst=dst, symlinks=symlinks, File "/home/irie/build/blender/make/blender-v2.93-release/bin/2.93/python/lib/python3.9/shutil.py", line 513, in _copytree raise Error(errors) shutil.Error: [('/home/irie/.config/blender/2.92/scripts/addons/manuelbastionilab', '/home/irie/.config/blender/2.93/scripts/addons/manuelbastionilab', "[Errno 2] No such file or directory: '/home/irie/.config/blender/2.92/scripts/addons/manuelbastionilab'")] location: <unknown location>:-1 ``` `shutil.copytree()` in userpref.py seems to need an optional argmuent `symlinks=True`, which has been removed in 216291ddb3 though I'm not sure why @brecht removed it. I confirmed the following patch resolves the issue: ``` diff --git a/release/scripts/startup/bl_operators/userpref.py b/release/scripts/startup/bl_operators/userpref.py index 3969386bad7..dd84dfa2df8 100644 --- a/release/scripts/startup/bl_operators/userpref.py +++ b/release/scripts/startup/bl_operators/userpref.py @@ -153,7 +153,7 @@ class PREFERENCES_OT_copy_prev(Operator): def execute(self, _context): import shutil - shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True) + shutil.copytree(self._old_path(), self._new_path(), dirs_exist_ok=True, symlinks=True) # reload preferences and recent-files.txt bpy.ops.wm.read_userpref() ```
Author
Member

Added subscribers: @brecht, @IRIEShinsuke

Added subscribers: @brecht, @IRIEShinsuke

This issue was referenced by 46a14bd6a3

This issue was referenced by 46a14bd6a317ead29dfdbf038bd30d49a656249e

symlinks=True was implicitly assumed in the custom implementation. I'll restore it now we use the built-in implementation.

`symlinks=True` was implicitly assumed in the custom implementation. I'll restore it now we use the built-in implementation.

Changed status from 'Needs Triage' to: 'Resolved'

Changed status from 'Needs Triage' to: 'Resolved'
Brecht Van Lommel self-assigned this 2021-05-31 18:23:44 +02:00
Thomas Dinges added this to the 2.93 LTS milestone 2023-02-07 18:46:13 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
EEVEE & Viewport
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
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#88670
No description provided.