blink.cmp icon indicating copy to clipboard operation
blink.cmp copied to clipboard

EPERM: operation not permitted [Windows]

Open FlippingBinary opened this issue 9 months ago • 1 comments

Make sure you have done the following

  • [x] Updated to the latest version of blink.cmp
  • [x] Searched for existing issues and documentation (try <C-k> on https://cmp.saghen.dev)

Bug Description

When starting NeoVim/LazyVim after updating plugins in PowerShell on Windows 11, I saw three messages:

[blink.cmp]: Downloading pre-built binary
[blink.cmp]: Falling back to Lua implementation due to error while downloading pre-built binary:
EPERM: operation not permitted: C:/Users/WDAGUtilityAccount/AppData/Local/nvim-data/lazy/blink.cmp/target/release/libblink_cmp_fuzzy.dll.tmp -> C:/Users/WDAGUtilityAccount/AppData/Local/nvim-data/lazy/blink.cmp/target/release/libblink_cmp_fuzzy.dll
[blink.cmp]: Set `fuzzy.implementation = 'prefer_rust' | 'lua'` to suppress this warning.

The EPERM error can occur when attempting to overwrite a file that already exists, so I closed every running instance of NeoVim and reopened one. This time, the only message was:

[blink.cmp]: Downloading pre-built binary

This appears to have confirmed the problem. On Windows, blink.cmp is attempting overwrite a file in a way that would immediately delete it, which fails if the file is open. Windows doesn't allow that by default. There are a few ways of handling it, such as by using the FILE_SHARE_DELETE flag when opening the file or renaming the old one so the filename becomes available. There is a way that a file can be unlinked so Windows will remove it from disk once the last handle is closed. I believe libuv does this correctly, but the filename can't be reused until Windows gets around to deleting the file.

Relevant configuration


neovim version

NVIM v0.10.2 Build type: Release LuaJIT 2.1.1713484068

blink.cmp version

v0.14.1

FlippingBinary avatar Mar 24 '25 16:03 FlippingBinary

I don't have a windows machine to test on but I'd happily accept a PR fixing this

saghen avatar Mar 24 '25 16:03 saghen