Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of local plugin generates symlink to origin directory, not to other symlinks #1220

Open
ArtAndreev opened this issue Mar 8, 2023 · 0 comments
Labels
bug v1 An issue or PR relevant to packer v2

Comments

@ArtAndreev
Copy link

Packer generates symlinks to origin directory for local plugins, not to other symlinks. This leads to problem with updating local plugins if they are managed with package manager like brew. After updating origin directory will not exist and symlink will be broken. See steps below.

  • nvim --version:

    Output
    NVIM v0.8.3
    Build type: Release
    LuaJIT 2.1.0-beta3
    Compiled by [email protected]
    
    Features: +acl +iconv +tui
    See ":help feature-compile"
    
       system vimrc file: "$VIM/sysinit.vim"
      fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.8.3/share/nvim"
    
    Run :checkhealth for more info
    
  • git --version:
    git version 2.39.2

  • Operating system/version:
    macOS: Version 13.2.1 (22D68)

  • Terminal name/version:
    Alacritty: Version 0.12.0-rc1 (1)

Steps to reproduce

  1. Run nvim and add some local plugin installed with brew to plugins, for example, use '/opt/homebrew/opt/fzf';
  2. Run :PackerSync;
  3. Exit nvim;
  4. Go to plugins installation directory: run cd ~/.local/share/nvim/site/pack/packer/start;
  5. Run ls -lah.

Actual behaviour

Find local plugin, in this case, it's fzf. Symlink points to Cellar, where package is stored: fzf@ -> /opt/homebrew/Cellar/fzf/0.38.0 .

Expected behaviour

fzf@ -> /opt/homebrew/opt/fzf.
ls -lah /opt/homebrew/opt/fzf shows /opt/homebrew/opt/fzf@ -> ../Cellar/fzf/0.38.0, so the chain is ~/.local/share/nvim/site/pack/packer/start/fzf@ -> /opt/homebrew/opt/fzf@ -> /opt/homebrew/Cellar/fzf/0.38.0.
After updating fzf to next version, for example, to 0.39.0, the directory 0.38.0 will be removed and 0.39.0 created, symlink /opt/homebrew/opt/fzf will be recreated pointing to 0.39.0. So the symlink in packer/start will not be broken.

packer files

Plugin specification file(s)
local ensure_packer = function()
  local fn = vim.fn
  local install_path = fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
  if fn.empty(fn.glob(install_path)) > 0 then
    fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
    vim.cmd [[packadd packer.nvim]]
    return true
  end
  return false
end

local packer_bootstrap = ensure_packer()

return require('packer').startup(function(use)
  use 'wbthomason/packer.nvim'

  use 'AndrewRadev/splitjoin.vim'
  if vim.fn.executable('fzf') then
    use '/opt/homebrew/opt/fzf'
    use 'junegunn/fzf.vim'
  end
  use 'preservim/nerdtree'
  use 'Xuyuanp/nerdtree-git-plugin'
  use 'tpope/vim-fugitive'
  use 'junegunn/gv.vim'
  use 'preservim/nerdcommenter'
  use 'tpope/vim-surround'
  use 'sainnhe/sonokai'
  use 'mhinz/vim-signify'
  use 'LunarWatcher/auto-pairs'
  use 'vim-airline/vim-airline'
  use 'vim-airline/vim-airline-themes'
  use 'prabirshrestha/asyncomplete.vim'
  if vim.fn.has('python3') then
    use 'SirVer/ultisnips'
    use 'prabirshrestha/asyncomplete-ultisnips.vim'
  end
  use 'prabirshrestha/vim-lsp'
  use 'prabirshrestha/asyncomplete-lsp.vim'
  use 'thomasfaingnaert/vim-lsp-snippets'
  if vim.fn.has('python3') then
    use 'thomasfaingnaert/vim-lsp-ultisnips'
  end
  use 'dense-analysis/ale'
  use 'rhysd/vim-lsp-ale'
  use 'dag/vim-fish'
  use 'vim-test/vim-test'
  use 'puremourning/vimspector'
  use 'wsdjeg/vim-fetch'
  use 'junegunn/vim-easy-align'
  use 'buoto/gotests-vim'
  use 'rhysd/vim-go-impl'
  use 'ryanoasis/vim-devicons'

  if packer_bootstrap then
    require('packer').sync()
  end
end)
packer log file

nothing

packer compiled file
-- Automatically generated packer.nvim plugin loader code

if vim.api.nvim_call_function('has', {'nvim-0.5'}) ~= 1 then
  vim.api.nvim_command('echohl WarningMsg | echom "Invalid Neovim version for packer.nvim! | echohl None"')
  return
end

vim.api.nvim_command('packadd packer.nvim')

local no_errors, error_msg = pcall(function()

_G._packer = _G._packer or {}
_G._packer.inside_compile = true

local time
local profile_info
local should_profile = false
if should_profile then
  local hrtime = vim.loop.hrtime
  profile_info = {}
  time = function(chunk, start)
    if start then
      profile_info[chunk] = hrtime()
    else
      profile_info[chunk] = (hrtime() - profile_info[chunk]) / 1e6
    end
  end
else
  time = function(chunk, start) end
end

local function save_profiles(threshold)
  local sorted_times = {}
  for chunk_name, time_taken in pairs(profile_info) do
    sorted_times[#sorted_times + 1] = {chunk_name, time_taken}
  end
  table.sort(sorted_times, function(a, b) return a[2] > b[2] end)
  local results = {}
  for i, elem in ipairs(sorted_times) do
    if not threshold or threshold and elem[2] > threshold then
      results[i] = elem[1] .. ' took ' .. elem[2] .. 'ms'
    end
  end
  if threshold then
    table.insert(results, '(Only showing plugins that took longer than ' .. threshold .. ' ms ' .. 'to load)')
  end

  _G._packer.profile_output = results
end

time([[Luarocks path setup]], true)
local package_path_str = "/Users/artyom/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?.lua;/Users/artyom/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/?/init.lua;/Users/artyom/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?.lua;/Users/artyom/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/?/init.lua"
local install_cpath_pattern = "/Users/artyom/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/?.so"
if not string.find(package.path, package_path_str, 1, true) then
  package.path = package.path .. ';' .. package_path_str
end

if not string.find(package.cpath, install_cpath_pattern, 1, true) then
  package.cpath = package.cpath .. ';' .. install_cpath_pattern
end

time([[Luarocks path setup]], false)
time([[try_loadstring definition]], true)
local function try_loadstring(s, component, name)
  local success, result = pcall(loadstring(s), name, _G.packer_plugins[name])
  if not success then
    vim.schedule(function()
      vim.api.nvim_notify('packer.nvim: Error running ' .. component .. ' for ' .. name .. ': ' .. result, vim.log.levels.ERROR, {})
    end)
  end
  return result
end

time([[try_loadstring definition]], false)
time([[Defining packer_plugins]], true)
_G.packer_plugins = {
  ale = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/ale",
    url = "https://github.com/dense-analysis/ale"
  },
  ["asyncomplete-lsp.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/asyncomplete-lsp.vim",
    url = "https://github.com/prabirshrestha/asyncomplete-lsp.vim"
  },
  ["asyncomplete-ultisnips.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/asyncomplete-ultisnips.vim",
    url = "https://github.com/prabirshrestha/asyncomplete-ultisnips.vim"
  },
  ["asyncomplete.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/asyncomplete.vim",
    url = "https://github.com/prabirshrestha/asyncomplete.vim"
  },
  ["auto-pairs"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/auto-pairs",
    url = "https://github.com/LunarWatcher/auto-pairs"
  },
  fzf = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/fzf",
    url = "/opt/homebrew/opt/fzf"
  },
  ["fzf.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/fzf.vim",
    url = "https://github.com/junegunn/fzf.vim"
  },
  ["gotests-vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/gotests-vim",
    url = "https://github.com/buoto/gotests-vim"
  },
  ["gv.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/gv.vim",
    url = "https://github.com/junegunn/gv.vim"
  },
  nerdcommenter = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/nerdcommenter",
    url = "https://github.com/preservim/nerdcommenter"
  },
  nerdtree = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/nerdtree",
    url = "https://github.com/preservim/nerdtree"
  },
  ["nerdtree-git-plugin"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/nerdtree-git-plugin",
    url = "https://github.com/Xuyuanp/nerdtree-git-plugin"
  },
  ["packer.nvim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/packer.nvim",
    url = "https://github.com/wbthomason/packer.nvim"
  },
  sonokai = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/sonokai",
    url = "https://github.com/sainnhe/sonokai"
  },
  ["splitjoin.vim"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/splitjoin.vim",
    url = "https://github.com/AndrewRadev/splitjoin.vim"
  },
  ultisnips = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/ultisnips",
    url = "https://github.com/SirVer/ultisnips"
  },
  ["vim-airline"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-airline",
    url = "https://github.com/vim-airline/vim-airline"
  },
  ["vim-airline-themes"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-airline-themes",
    url = "https://github.com/vim-airline/vim-airline-themes"
  },
  ["vim-devicons"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-devicons",
    url = "https://github.com/ryanoasis/vim-devicons"
  },
  ["vim-easy-align"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-easy-align",
    url = "https://github.com/junegunn/vim-easy-align"
  },
  ["vim-fetch"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-fetch",
    url = "https://github.com/wsdjeg/vim-fetch"
  },
  ["vim-fish"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-fish",
    url = "https://github.com/dag/vim-fish"
  },
  ["vim-fugitive"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-fugitive",
    url = "https://github.com/tpope/vim-fugitive"
  },
  ["vim-go-impl"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-go-impl",
    url = "https://github.com/rhysd/vim-go-impl"
  },
  ["vim-lsp"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-lsp",
    url = "https://github.com/prabirshrestha/vim-lsp"
  },
  ["vim-lsp-ale"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-lsp-ale",
    url = "https://github.com/rhysd/vim-lsp-ale"
  },
  ["vim-lsp-snippets"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-lsp-snippets",
    url = "https://github.com/thomasfaingnaert/vim-lsp-snippets"
  },
  ["vim-lsp-ultisnips"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-lsp-ultisnips",
    url = "https://github.com/thomasfaingnaert/vim-lsp-ultisnips"
  },
  ["vim-signify"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-signify",
    url = "https://github.com/mhinz/vim-signify"
  },
  ["vim-surround"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-surround",
    url = "https://github.com/tpope/vim-surround"
  },
  ["vim-test"] = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vim-test",
    url = "https://github.com/vim-test/vim-test"
  },
  vimspector = {
    loaded = true,
    path = "/Users/artyom/.local/share/nvim/site/pack/packer/start/vimspector",
    url = "https://github.com/puremourning/vimspector"
  }
}

time([[Defining packer_plugins]], false)

_G._packer.inside_compile = false
if _G._packer.needs_bufread == true then
  vim.cmd("doautocmd BufRead")
end
_G._packer.needs_bufread = false

if should_profile then save_profiles() end

end)

if not no_errors then
  error_msg = error_msg:gsub('"', '\\"')
  vim.api.nvim_command('echohl ErrorMsg | echom "Error in packer_compiled: '..error_msg..'" | echom "Please check your config for correctness" | echohl None')
end
@ArtAndreev ArtAndreev added bug v1 An issue or PR relevant to packer v2 labels Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug v1 An issue or PR relevant to packer v2
Projects
None yet
Development

No branches or pull requests

1 participant