matthewjberger / scoop-nerd-fonts

A scoop bucket for installing nerd fonts
The Unlicense
353 stars 34 forks source link

'Cascadia-Code' (2106.17) upgrade fails when fonts are in use #146

Closed arielsalvo closed 1 year ago

arielsalvo commented 2 years ago

Cascadia Code installer fails to update the font files if they are already in use.

Example:

Copy-Item : The process cannot access the file 'C:\WINDOWS\Fonts\CascadiaCode.ttf' because it is being used by another process.
At line:4 char:5
+     Copy-Item $_.FullName -destination "$env:windir\Fonts"
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Copy-Item], IOException
    + FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.Commands.CopyItemCommand

Still, this is not detected: 'Cascadia-Code' (2108.26) was installed successfully!

Maybe change the installer to copy those on next reboot if the files are locked?

Thanks! --Ariel

tan-wei commented 2 years ago

You can first remove it, then after restart the system, do a fresh install.

arielsalvo commented 2 years ago

@tan-wei That could work but probably not as you think. If you take a look at the code for the removal, lines 24 and 25, you'll see that if the files are in use it would just fail silently at removing them. Then, when you restart the system the files will be released, allowing you to overwrite them with your fresh installation. The fonts would not really be uninstalled and this would not be any better than restarting the system before attempting to upgrade the fonts.

I mean, there are plenty of workarounds but the package is not working correctly here: at the very least, the error in the installer/remover code should translate in failure to install/remove package and not silently failing and moving on.

tan-wei commented 2 years ago

@abejenaru Got it. Actually, I always use this "workaround" to upgrade fonts :-(, it is not elegant.

david-bakin commented 2 years ago

[Using shovel installer instead of scoop installer ...]

 R:\>shovel update Cascadia-Code imagemagick
 Cascadia-Code: 2108.26 -> 2110.31
 imagemagick: 7.1.0-12 -> 7.1.0-13
 Updating 2 outdated apps:
 Updating 'Cascadia-Code' (2108.26 -> 2110.31) [64bit]
 Downloading new version
 Starting download with aria2 ...
   >>> DOWNLOAD ELIDED <<<
 Download: (OK):download completed.
 Checking hash of CascadiaCode-2110.31.zip ... ok.
 Uninstalling 'Cascadia-Code' (2108.26)
 Running uninstaller script...
 The 'Cascadia-Code' font family has been uninstalled and will not be present after restarting your computer.
 Unlinking ~\scoop\apps\Cascadia-Code\current
 Installing 'Cascadia-Code' (2110.31) [64bit] [nerd-fonts]
 WARN  By installing you accept following license: OFL-1.1 (https://spdx.org/licenses/OFL-1.1.html)
 Loading CascadiaCode-2110.31.zip from cache.
 Extracting CascadiaCode-2110.31.zip ... done.
 Running installer script...
+
-ERROR The requested operation cannot be performed on a file with a user-mapped section open.