stevearc / oil.nvim

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

bug: Cant open files "Could not find oil adapter for scheme ://" #362

Open VoreckLukas opened 2 months ago

VoreckLukas commented 2 months ago

Did you check the docs and existing issues?

Neovim version (nvim -v)

NVIM v0.9.5

Operating system/version

NixOS Unstable

Describe the bug

Whenever I try to open a file with oil i get the error above along with the following:

E5108: Error executing lua: ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/util.lua:825: assertion failed!
stack traceback:
    [C]: in function 'assert'
    ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/util.lua:825: in function 'get_edit_path'
    ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/init.lua:668: in function 'open_next_entry'
    ...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/init.lua:705: in function <...ir/pack/myNeovimPackages/start/oil.nvim/lua/oil/init.lua:550>

It seems to only happen when oil is opened floating

What is the severity of this bug?

breaking (some functionality is broken)

Steps To Reproduce

  1. nvim -u repro.lua
  2. :lua require("oil").open_float()
  3. Select a file and press enter

Expected Behavior

The file should be opened

Directory structure

Any

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

Did you check the bug with a clean config?

stevearc commented 2 months ago

Please ensure you are on the most recent version of oil and provide a minimal init.lua file, such as provided in the bug report template. Ensure that the error reproduces when using that minimal init file.

VoreckLukas commented 2 months ago

Please ensure you are on the most recent version of oil and provide a minimal init.lua file, such as provided in the bug report template. Ensure that the error reproduces when using that minimal init file.

Where can i see the version?

I have provided the minimal init file which im using and I can reliably reproduce it. to prove it I have a gif here

vim

VoreckLukas commented 2 months ago

Oh I just realized that the repro.lua in the template also has stuff to change paths etc. still with the exact template from the bug report (

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "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",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

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

) It still happens exactly the same, perfectly reproducible

dileep-kishore commented 2 months ago

I have the same issue. Neovim version: v0.9.5 on NixOS unstable. This only happens when using open_float()

PowwwaN commented 2 months ago

I have the same issue

$ nvim -v
NVIM v0.9.5
Build type: Release
LuaJIT 2.1.1693350652

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/aszfdv0palw8vgpswijvgn273fip4306-neovim-unwrapped-0.9.5/share/nvim
"

Run :checkhealth for more info

Only in floating mode.

stevearc commented 2 months ago

Crazy, this seems to only be happening in NixOS, and the issue is that where we expect to have the oil bufnr, instead we have a handle to the repro.lua bufnr. That means that somewhere in this block of code the current buffer changes from the oil buffer to the target file. https://github.com/stevearc/oil.nvim/blob/010b44a79d497c697686e2727049d3dd215bbbd6/lua/oil/init.lua#L589-L643

There shouldn't be any way for that to happen, and it especially shouldn't be platform-dependent. I added a couple of debug print statements to this branch: https://github.com/stevearc/oil.nvim/tree/stevearc-nix-test Could you do the repro again and show me what it prints when the error happens?

PowwwaN commented 2 months ago

and it especially shouldn't be platform-dependent

For me, the issue occurs now only when I install and set up Oil through nixos package-manager. With Lazy everything works good, without any errors.

VoreckLukas commented 1 month ago

when installing oil like this

      package = pkgs.vimUtils.buildVimPlugin {
        pname = "oil.nvim";
        version = "2023-11-16";
        src = pkgs.fetchFromGitHub {
          owner = "stevearc";
          repo = "oil.nvim";
          rev = "3151d9dd616ea33fa219dd4b198f01c49d8f76c3";
          sha256 = "17mi1hs3jmmrxqxhykqf0xj91ssxzzzig7gmdlyak6pgwln2ziyr";
          fetchSubmodules = true;
        };
        meta.homepage = "https://github.com/stevearc/oil.nvim/";
      };

To check out your branch it doesn't happen anymore @stevearc

stevearc commented 1 month ago

@VoreckLukas that's concerning, because all I did in that branch is add some print statements. That might indicate that the issue is a very consistent race condition. I've reworked that branch to write to a log file instead of printing to hopefully get the error to trigger again. If you can get it to repro, the logs should be under ~/.local/state/nvim/oil.log (or if your XDG directories are different on NixOS, you can find the dir with :echo stdpath('log')).

VoreckLukas commented 1 month ago

I was a bit busy the last few Weeks and will try the branch out in a few days. Has to be noted though that the standard package delivered by nixpkgs works again