Compare commits

...

1 Commits

Author SHA1 Message Date
Dmitriy Kovalenko 461a615878 fix: Not downloadable binary
docs / docs (push) Has been cancelled
closes https://github.com/dmtrKovalenko/fff.nvim/issues/196

This issue was related to the fact that I chagned vim.mkdir to
vim.uv.fs_mkdir but it is not recursive so when you installed a fresh
version it never created the dir for it.
2025-12-18 18:05:11 -08:00
3 changed files with 41 additions and 8 deletions
+6 -6
View File
@@ -1,6 +1,5 @@
local M = {}
local system = require('fff.utils.system')
local uv = vim and vim.uv or require('luv')
local GITHUB_REPO = 'dmtrKovalenko/fff.nvim'
@@ -24,7 +23,7 @@ end
local function binary_exists(plugin_dir)
local binary_path = get_binary_path(plugin_dir)
local stat = uv.fs_stat(binary_path)
local stat = vim.uv.fs_stat(binary_path)
return stat and stat.type == 'file'
end
@@ -32,9 +31,10 @@ local function download_file(url, output_path, opts, callback)
opts = opts or {}
local dir = vim.fn.fnamemodify(output_path, ':h')
uv.fs_mkdir(dir, 493, function(err) -- 493 = 0755 octal
if err and not err:match('EEXIST') then
callback(false, 'Failed to create directory: ' .. err)
mkdir_recursive(dir, function(mkdir_ok, mkdir_err)
if not mkdir_ok then
callback(false, mkdir_err)
return
end
@@ -89,7 +89,7 @@ local function download_from_github(version, binary_path, opts, callback)
local ok, err_msg = pcall(function() package.loadlib(binary_path, 'luaopen_fff_nvim') end)
if not ok then
uv.fs_unlink(binary_path)
vim.uv.fs_unlink(binary_path)
callback(false, 'Downloaded binary is not valid: ' .. (err_msg or 'unknown error'))
return
end
+4 -2
View File
@@ -37,6 +37,7 @@ local function try_load_library()
local stat = vim.uv.fs_stat(actual_path)
if stat and stat.type == 'file' then
local loader, err = package.loadlib(actual_path, 'luaopen_fff_nvim')
if err then return nil, string.format('Error loading library from %s: %s', actual_path, err) end
if loader then return loader() end
end
end
@@ -44,12 +45,13 @@ local function try_load_library()
end
local backend, load_err = try_load_library()
if not backend then
if not backend or load_err then
local err_msg = string.format(
'Failed to load fff rust backend.\nError: %s\nSearched paths:\n%s\nMake sure binary exists with `cargo build --release`',
'Failed to load fff rust backend.\nError: %s\nSearched paths:\n%s\nMake sure binary exists or make it exists using \n `:lua require("fff.download").download_or_build_binary()`\nor\n`cargo build --release`\n(and rerun neovim after)',
tostring(load_err),
vim.inspect(paths)
)
error(err_msg)
end
+31
View File
@@ -59,4 +59,35 @@ function M.is_one_of(value, values)
return false
end
-- Recursively create directories using uv.fs_mkdir
local function mkdir_recursive(path, callback)
vim.uv.fs_stat(path, function(err, stat)
if not err and stat then
callback(true, nil)
return
end
local parent = vim.fn.fnamemodify(path, ':h')
if parent == path or parent == '' or parent == '.' then
callback(false, 'Cannot create root directory')
return
end
mkdir_recursive(parent, function(parent_ok, parent_err)
if not parent_ok then
callback(false, parent_err)
return
end
uv.fs_mkdir(path, 493, function(mkdir_err) -- 493 = 0755 octal
if mkdir_err and not mkdir_err:match('EEXIST') then
callback(false, 'Failed to create directory: ' .. mkdir_err)
return
end
callback(true, nil)
end)
end)
end)
end
return M