stevearc / oil.nvim

Neovim file explorer: edit your filesystem like a buffer
MIT License
3.36k stars 91 forks source link

bug: Cannot open oil #409

Closed t18n closed 1 week ago

t18n commented 3 weeks ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

0.10.0

Operating system/version

MacOS 14.4.1

Describe the bug

After updating to the latest stable Nvim version and the latest Oil, the plugin does not display the root directory anymore.

Error shown:

   Error  10:54:48 notify.error lazy.nvim Failed to run `config` for oil.nvim

...s/turbo/.local/share/nvim/lazy/oil.nvim/lua/oil/util.lua:159: E565: Not allowed to change text or change window

# stacktrace:
  - /oil.nvim/lua/oil/util.lua:159 _in_ **rename_buffer**
  - /oil.nvim/lua/oil/init.lua:746 _in_ **maybe_hijack_directory_buffer**
  - /oil.nvim/lua/oil/init.lua:1265 _in_ **setup**

https://github.com/stevearc/oil.nvim/assets/14198542/36fc4cf6-6ece-4f9c-a2af-030b99feb2ff

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

Unfortunately I cannot reproduce this with the repro. So creating the issue with the hope to get some inputs.

Expected Behavior

Oil should not show any error and work with root directory

Directory structure

No response

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
    'stevearc/oil.nvim',
    opts = {},
    -- Optional dependencies
    dependencies = { "nvim-tree/nvim-web-devicons" },
  }
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here

Did you check the bug with a clean config?

t18n commented 3 weeks ago

I found a workaround for now: after opening Nvim, I use Telescope to open a random file before open Oil, it will then work as normal. Hopefully this can be fixed :)

stevearc commented 3 weeks ago

Since you can't reproduce the issue with a clean config, it's most likely interference with some other plugin. The message

E565: Not allowed to change text or change window

seems to be related to autocomplete. So maybe you're loading oil in the middle of a completion function somehow.

The last resort to figure out the conflict is always to :help bisect

jellydn commented 3 weeks ago

FYI - I've got the same issue and use lazy.nvim to pin to the commit 18272aba9d00a3176a5443d50dbb4464acc167bd to make it works.

  {
    "stevearc/oil.nvim",
    commit = "18272aba9d00a3176a5443d50dbb4464acc167bd",
    opts = { }
  }
jellydn commented 3 weeks ago

FYI - It's working for me with last commit now.

NicolasGB commented 3 weeks ago

Same, it's working again. I've also noted that the "actions.save" which i had mapped is gone now, i replaced it with vim.cmd.w

stevearc commented 3 weeks ago

@t18n does the most recent commit work for you as well?

t18n commented 2 weeks ago

@jellydn unfortunately commit = "18272aba9d00a3176a5443d50dbb4464acc167bd", did not work for me.

@stevearc I updated to

  "oil.nvim": { "branch": "master", "commit": "64a3a555b40d96faae488ed6cf5d0f8b38520891" },

but the issue persisted.

stevearc commented 2 weeks ago

@t18n the only clue I have is that it might be related to autocomplete somehow. It's definitely a bad interaction with something else in your config, but without being able to reproduce it on my end I can't look into it. As mentioned before, you could try :help bisect. Another place to look could be using :Lazy to see what triggered the loading of oil.nvim, because it looks like the error is happening in the setup function, so it's possible that oil is getting loaded in a weird or unexpected context.

Divelix commented 1 week ago

I disabled lazy load for oil and now it works fine.

t18n commented 1 week ago

@Divelix that's it. Set lazy = false fixed it for me. Thank you!