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

bug: Error when deleting dangling symlink with delete_to_trash set to true #251

Closed
3 tasks done
Bekaboo opened this issue Dec 7, 2023 · 2 comments
Closed
3 tasks done
Labels
bug Something isn't working P0 Highest priority, will receive attention

Comments

@Bekaboo
Copy link
Contributor

Bekaboo commented Dec 7, 2023

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.10.0-dev-1627+g879617c9bb

Operating system/version

Linux 6.1.60-1-lts

Describe the bug

Error when deleting dangling symlink with delete_to_trash set to true:

E5108: Error executing lua: ...es/start/oil.nvim/lua/oil/adapters/trash/freedesktop.lua:78: attempt to index a nil value

stack traceback:
        ...es/start/oil.nvim/lua/oil/adapters/trash/freedesktop.lua:78: in function 'get_write_trash_dir'
        ...es/start/oil.nvim/lua/oil/adapters/trash/freedesktop.lua:523: in function 'create_trash_info'
        ...es/start/oil.nvim/lua/oil/adapters/trash/freedesktop.lua:618: in function 'delete_to_trash'
        .../pack/packages/start/oil.nvim/lua/oil/adapters/files.lua:514: in function 'perform_action'
        ...te/pack/packages/start/oil.nvim/lua/oil/mutator/init.lua:454: in function 'next_action'
        ...te/pack/packages/start/oil.nvim/lua/oil/mutator/init.lua:457: in function 'process_actions'
        ...te/pack/packages/start/oil.nvim/lua/oil/mutator/init.lua:537: in function 'cb'
        ...pack/packages/start/oil.nvim/lua/oil/mutator/preview.lua:129: in function 'confirm'
        ...pack/packages/start/oil.nvim/lua/oil/mutator/preview.lua:177: in function <...pack/packages/start/oil.nvim/lu
a/oil/mutator/preview.lua:176>

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. Create minimal init.lua as shown below
  2. Create a dangling symlink: ln -s foo bar
  3. nvim --clean -u init.lua .
  4. Goto the symlink, delete it in oil buffer, save it and confirm deletion
  5. See the error

Expected Behavior

No error

Directory structure

bar -> foo (broken link)

Repro

local tmp = '/tmp'
local data = tmp .. '/' .. (vim.env.NVIM_APPNAME or 'nvim')
local package_root = data .. '/site'
local clone_root = package_root .. '/pack/packages/start'
local clone_info = {
  {
    path = clone_root .. '/oil.nvim',
    url = 'https://github.com/stevearc/oil.nvim.git',
  },
}

vim.fn.mkdir(clone_root, 'p')
vim.opt.pp:prepend(package_root)
vim.opt.rtp:prepend(package_root)
vim.opt.mousemoveevent = true

for _, info in ipairs(clone_info) do
  if not vim.loop.fs_stat(info.path) then
    vim.notify('cloning ' .. info.url, vim.log.levels.INFO)
    vim.fn.system({ 'git', 'clone', info.url, info.path })
  end
end

require('oil').setup({
  delete_to_trash = true,
})

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.
@Bekaboo Bekaboo added the bug Something isn't working label Dec 7, 2023
@stevearc stevearc added the P0 Highest priority, will receive attention label Dec 24, 2023
@stevearc
Copy link
Owner

Should be fixed

@Bekaboo
Copy link
Contributor Author

Bekaboo commented Dec 26, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working P0 Highest priority, will receive attention
Projects
None yet
Development

No branches or pull requests

2 participants