pckr.nvim icon indicating copy to clipboard operation
pckr.nvim copied to clipboard

Cannot install plugins from non-GitHub URLs on Windows due to bad path splitting/lack of sanitization

Open wrldspawn opened this issue 1 year ago • 1 comments

  • nvim --version: v0.10.2, Build type: Release, LuaJIT 2.1.1713484068
  • git --version: 2.46.2.windows.1
  • Operating system/version: Windows 10 22H2
  • Terminal name/version: WezTerm 20240812-215703-30345b36

Steps to reproduce

Attempt to install a plugin from a non-GitHub URL (e.g. "https://git.sr.ht/~whynothugo/lsp_lines.nvim")

Actual behaviour

fatal: could not create leading directories of 'C:\Users\User\AppData\Local\nvim-data/site/pack/pckr/opt/https:/git.sr.ht/~whynothugo/lsp_lines.nvim': Invalid argument

Expected behaviour

Path does not include https:// nor colons or any other characters Windows disallows in filepaths

pckr files

Plugin specification file(s)
local function bootstrap_pckr()
	local pckr_path = vim.fn.stdpath("data") .. "/pckr/pckr.nvim"

	if not (vim.uv or vim.loop).fs_stat(pckr_path) then
		vim.fn.system({
			"git",
			"clone",
			"--filter=blob:none",
			"https://github.com/lewis6991/pckr.nvim",
			pckr_path
		})
	end

	vim.opt.rtp:prepend(pckr_path)
end

bootstrap_pckr()

require("pckr").add({
	"https://git.sr.ht/~whynothugo/lsp_lines.nvim",
})

wrldspawn avatar Oct 18 '24 02:10 wrldspawn

To add here, using local extensions does not seem to be working either, I get:

Error executing vim.schedule lua callback: ...ppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/async.lua:39: The coroutine failed with this message: ...l\nvim-data\pckr\pckr.nvim/lua/pckr/plugin_types/git.lua:186: bad argument #1 to 'assert' (value expected)                                                                                stack traceback:                                                                                                                                                                [C]: in function 'assert'                                                                                                                                               ...l\nvim-data\pckr\pckr.nvim/lua/pckr/plugin_types/git.lua:186: in function 'get_head'                                                                                 ...l\nvim-data\pckr\pckr.nvim/lua/pckr/plugin_types/git.lua:488: in function 'update'                                                                                   ...l\nvim-data\pckr\pckr.nvim/lua/pckr/plugin_types/git.lua:578: in function 'updater'                                                                                  ...AppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/sync.lua:220: in function <...AppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/sync.lua:210>                  stack traceback:                                                                                                                                                                [C]: in function 'error'                                                                                                                                                ...ppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/async.lua:39: in function 'cb'                                                                                        ...ppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/async.lua:79: in function <...ppData\Local\nvim-data\pckr\pckr.nvim/lua/pckr/async.lua:78>

I am trying to improve an existing library without forking the project, but I guess this is the only option

davidoroian avatar Apr 03 '25 14:04 davidoroian