Change:
<!-- Do Not Delete This! bugreporttemplate --<!-- Please read our Rules of Conduct: --<!-- Read our guide about submitting issues: --<!-- Search existing issues to avoid creating duplicates. --<!-- Test using the latest Insiders build to see if your issue has already been fixed: --<!-- Instead of creating your report here, use 'Report Issue' from the 'Help' menu in VS Code to pre-fill useful information. --<!-- Launch with to check. --Does this issue occur when all extensions are disabled?: Yes <!-- If you answered No above, use 'Help: Start Extension Bisect' from Command Palette to try to identify the cause. --<!-- Issues caused by an extension need to be reported directly to the extension publisher. The 'Help Report Issue' dialog can assist with this. --- VS Code Version: 1.86.0- OS Version: Debian/testing Steps to Reproduce: previous version already installed the (deprecated) /etc/apt/trusted key folders to /etc/apt/keyrings/ and rewrite all ".list" files with the new format ".sources" update dist-upgrade again After step 4 apt complains about a missing directory: After step 5 it will have created a functional duplicate of as ; this is somehow related to in that the root cause is always the same, main difference is that the key file itself will apparently not be duplicated and apt won't complain (too much).
FYI a reasonable workaround is creating an empty file, then making it mode 444 and immutable. No error is reported on upgrade and no unwanted changes to apt sources occur.
Closing in favour of

Discussion:
# Register apt repository eval $(apt-config shell APT_SOURCE_PARTS Dir::Etc::sourceparts/d) CODE_SOURCE_PART=${APT_SOURCE_PARTS}vscode.list <ins> CODE_SOURCE_PART_DEB822=${APT_SOURCE_PARTS}vscode.sources </ins> eval $(apt-config shell APT_TRUSTED_PARTS Dir::Etc::trustedparts/d) CODE_TRUSTED_PART=${APT_TRUSTED_PARTS}microsoft.gpg

db_get @@NAME@@/add-microsoft-repo || true fi <del> # Install repository source list </del> <ins> # Determine whether to install the repository source list </ins> WRITE_SOURCE=0 if [ "$RET" = false ]; then <del> # The user does not want to add the microsoft repository </del> <ins> # The user does not want to add the Microsoft repository </ins> WRITE_SOURCE=0 <del> elif grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART; then </del> <ins> elif [ -f "$CODE_SOURCE_PART_DEB822" ]; then # The user has migrated themselves to the DEB822 format WRITE_SOURCE=0 elif [ -f "$CODE_SOURCE_PART" ] && (grep -q "http://packages.microsoft.com/repos/vscode" $CODE_SOURCE_PART); then </ins> # Migrate from old repository WRITE_SOURCE=2 <del> elif grep -q "http://packages.microsoft.com/repos/code" $CODE_SOURCE_PART; then </del> <ins> elif [ -f "$CODE_SOURCE_PART" ] && (grep -q "http://packages.microsoft.com/repos/code" $CODE_SOURCE_PART); then </ins> # Migrate from old repository WRITE_SOURCE=2 elif apt-cache policy | grep -q "https://packages.microsoft.com/repos/code"; then <del> # Skip following checks if the repo is already known to apt </del> <ins> # The user is already on the new repository </ins> WRITE_SOURCE=0 elif [ ! -f $CODE_SOURCE_PART ] && [ ! -f /etc/rpi-issue ]; then # Write source list if it does not exist and we're not running on Raspberry Pi OS