Skip to content

bug: "No permission to access path" - replace_in_file tooling not working on windows #2094

@grichard99

Description

@grichard99

Describe the bug

Hello, I'd love some help on this as I've been struggling for a while now and can't seem to figure it out.

Each time I use the avante chat or ask, I get this response when it tries to actually edit the file I asked it to make changes on:

replace_in_file failed
│ running tool
│ path: C:/Users/guyri/Documents/Git/buggy_adventures/dragonruby-windows-amd64/mygame/app/main.rb
╰─ Error: No permission to access path: C:/Users/guyri/Documents/Git/buggy_adventures/dragonruby-windows-amd64/mygame/app/main.rb

On a different terminal (git bash, pwsh, etc), it gives the same error just different tool, e.g:

insert failed
│ running tool
│ path: C:/Users/guyri/Documents/Git/buggy_adventures/dragonruby-windows-amd64/mygame/app/main.rb
╰─ Error: No permission to access path: C:/Users/guyri/Documents/Git/buggy_adventures/dragonruby-windows-amd64/mygame/app/main.rb

That path is just my current directory, but it happens on any file in any directory.

I'm currently using Neovim on windows 11, with lazy.nvim package manager

I've currently tried:

  1. Running as administrator
  2. Running on different types of terminals
  3. Changing my neovim default terminal and giving it admin permissions in init.lua
  4. Changing files to full access on windows security/removing any "read-only" statuses
  5. Disabling all firewall/antivirus configurations
  6. Building from source instead of automatically
  7. Changing the LLM (tried claude sonnet 4 and chat-gpt-4o-mini)

I can edit files just fine through neovim and other plugins, but avante can't seem to get access, so I've come to you for help.

Thank you in advance!

To reproduce

Use AvanteAsk or AvanteChat to make edits to an open file

Expected behavior

Expected: Be able to make edits to the desired files I'm working on

Installation method

My lazy.nvim avante plugin file is:

return {
  {
    'yetone/avante.nvim',
    dir = vim.fn.stdpath('data') .. '/lazy/avante.nvim', -- Point to local clone
    event = 'VeryLazy',
    build = 'powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource true', -- Windows-specific build
    dependencies = {
      'stevearc/dressing.nvim',
      'nvim-lua/plenary.nvim',
      'MunifTanjim/nui.nvim',
      'nvim-tree/nvim-web-devicons',
    },
    opts = {
			    -- add any opts here
    -- for example
    provider = "openai",
    openai = {
      endpoint = "https://api.openai.com/v1",
      model = "gpt-4o-mini", -- your desired model (or use gpt-4o, etc.)
      timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models
      temperature = 0,
      max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models)
      --reasoning_effort = "medium", -- low|medium|high, only used for reasoning models
      },
      windows = {
        use_absolute_path = true, -- Critical for Windows path handling
        wrap_line = true,
        width = 30,
      },
      mappings = {
        ask = '<leader>aa',
        edit = '<leader>ae',
        refresh = '<leader>ar',
      },
      behaviour = {
        auto_set_keymaps = true,
        auto_apply_diff_after_generation = true,
      },
    },
    config = function(_, opts)
      require('avante').setup(opts)
    end,
  },
}

Environment

Neovim version: 0.10.02
OS: Windows 11
package manager: `lazy.nvim

Repro

### My basic init.lua file is:


require("config.lazy")


--NVIM TREE CONFIG RULES
-- disable netrw at the very start of your init.lua
vim.g.loaded_netrw = 1
vim.g.loaded_netrwPlugin = 1

-- optionally enable 24-bit colour
vim.opt.termguicolors = true

vim.opt.shell = 'powershell.exe'
vim.opt.shellcmdflag = '-NoProfile -ExecutionPolicy Bypass -Command'
vim.opt.shellquote = ''
vim.opt.shellxquote = ''
vim.opt.shellpipe = '>'
vim.opt.shellredir = '>'

root_dir = "C:\\Users\\guyri"

-- empty setup using defaults
require("nvim-tree").setup()

-- OR setup with some options
require("nvim-tree").setup({
  sort = {
    sorter = "case_sensitive",
  },
  view = {
    width = 30,
  },
  renderer = {
    group_empty = true,
  },
  filters = {
    dotfiles = true,
  },
})
--END OF NVIM TREE CONFIG RULES

Metadata

Metadata

Assignees

No one assigned

    Labels

    StalebugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions