Skip to content

Commit

Permalink
fix(windows): use junctions instead of symlinks (#509)
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb authored Aug 19, 2024
1 parent dd13ab6 commit 9374140
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lua/rocks/adapter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
-- Homepage: https://github.com/nvim-neorocks/rocks.nvim
-- Maintainers: NTBBloodbath <[email protected]>, Vhyrro <[email protected]>, mrcjkb <[email protected]>

-- NOTE: On Windows, we must create junctions, because NTFS symlinks require admin privileges.

local adapter = {}

local nio = require("nio")
Expand All @@ -41,11 +43,11 @@ local function create_symlink_sync(symlink_location, symlink_dir_name, dest_dir_
return true
else
log.debug(("Creating symlink directory: %s"):format(symlink_dir_name))
local success, err = vim.uv.fs_symlink(dest_dir_path, symlink_dir_path)
local success, err = vim.uv.fs_symlink(dest_dir_path, symlink_dir_path, { junction = true })
if not success then
log.error(("Error creating symlink directory: %s (%s)"):format(symlink_dir_name, err or "unknown error"))
end
return success
return success or false
end
end

Expand All @@ -57,7 +59,8 @@ local create_symlink_async = nio.create(function(symlink_location, symlink_dir_n
log.debug(("Symlink directory %s exists already."):format(symlink_dir_name))
else
log.debug(("Creating symlink directory: %s"):format(symlink_dir_name))
local err, success = nio.uv.fs_symlink(dest_dir_path, symlink_dir_path)
---@diagnostic disable-next-line: param-type-mismatch
local err, success = nio.uv.fs_symlink(dest_dir_path, symlink_dir_path, { junction = true })
if not success then
log.error(("Error creating symlink directory: %s (%s)"):format(symlink_dir_name, err or "unknown error"))
end
Expand Down

0 comments on commit 9374140

Please sign in to comment.