avante.nvim icon indicating copy to clipboard operation
avante.nvim copied to clipboard

bug: No permission to access path

Open magnusriga opened this issue 7 months ago • 10 comments

Describe the bug

Avante complains that it does not have permission to access files:

Image

After attempting to open it, it just deleted all the code in my file and was thus not able to find the code anymore.

I have no idea what is going on here. Is this plugin working for others and used in daily coding?

To reproduce

n/a/

Expected behavior

Expected it to have permissions.

Installation method

Use lazy.nvim:

{
  "yetone/avante.nvim",
  event = "VeryLazy",
  lazy = false,
  version = false, -- set this if you want to always pull the latest change
  opts = {
    -- add any opts here
  },
  -- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
  build = "make",
  -- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
  dependencies = {
    "nvim-treesitter/nvim-treesitter",
    "stevearc/dressing.nvim",
    "nvim-lua/plenary.nvim",
    "MunifTanjim/nui.nvim",
  },
}

Environment

v0.12

Repro

vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()

require("lazy.minit").repro({
  spec = {
    -- add any other plugins here
  },
})

magnusriga avatar Apr 29 '25 22:04 magnusriga

I do have the same error ever since updating, and the tools changed from showing the diff in the sidebar first to directly showing it in the files

barnabasJ avatar May 05 '25 14:05 barnabasJ

Same issue after updating

wwnbb avatar May 05 '25 22:05 wwnbb

I do have the same error ever since updating, and the tools changed from showing the diff in the sidebar first to directly showing it in the files

You can use mode = "legacy" to revert to the previous mode.

yetone avatar May 06 '25 17:05 yetone

@yetone thank you for chiming in. Do you know if the file permission issue is fixed, or if it is a problem on my/our end?

Also, is it advisable to disable all the avante tools like described in the mcphub docs, when using the two together?

magnusriga avatar May 07 '25 09:05 magnusriga

@magnusriga I have the same problem and I have disabled all the servers and mcphub plugin also but still no access

Vladipz avatar May 12 '25 19:05 Vladipz

I'm also having the same issue

Image

MoaidHathot avatar May 18 '25 08:05 MoaidHathot

I am also having the same issue

Image

felipejoribeiro avatar May 21 '25 00:05 felipejoribeiro

Same issue with latest Avante + MCPHub here.

Related Plugin Versions:

Error Message by LLM:

╭─  replace_in_file  failed
│   running tool
│   path: /home/user/mcphub/servers.json
╰─  Error: No permission to access path: /home/user/.config/mcphub/servers.json

I encountered an issue while trying to update the configuration file. It seems I don't have the necessary permissions to access `/home/user/.config/mcphub/servers.json`.

Could you please ensure that I have the correct permissions to modify this file?

ShangjinTang avatar May 21 '25 02:05 ShangjinTang

Same issue here

Image

MartinChekurov avatar May 24 '25 08:05 MartinChekurov

Using AI I was able to patch this locally temporarily:

➜ git diff
diff --git a/lua/avante/llm_tools/helpers.lua b/lua/avante/llm_tools/helpers.lua
index ef6cfe9..f478913 100644
--- a/lua/avante/llm_tools/helpers.lua
+++ b/lua/avante/llm_tools/helpers.lua
@@ -75,7 +75,11 @@ end
 function M.has_permission_to_access(abs_path)
   if not Path:new(abs_path):is_absolute() then return false end
   local project_root = Utils.get_project_root()
-  if abs_path:sub(1, #project_root) ~= project_root then return false end
+  -- allow if inside project root OR inside user config dir
+  local config_dir = vim.fn.stdpath('config')
+  local in_project = abs_path:sub(1, #project_root) == project_root
+  local in_config  = abs_path:sub(1, #config_dir)  == config_dir
+  if not in_project and not in_config then return false end
   return not M.is_ignored(abs_path)
 end

Note that I am seeing the codebase for the first time so please take the above with a grain of salt :)

My problem was that the agent was trying to modify a file in my config directory. You can adapt the fix for your usecase.

antonpetrovmain avatar May 24 '25 12:05 antonpetrovmain

There is a bug problem and I cannot find a real solution . Could someone help or say that it will or not be fixed

Vladipz avatar May 31 '25 22:05 Vladipz

I did some debugging and found that vim.fs.normalize converts backslashes () into forward slashes (/). This causes the project_root path to differ from abs_path when checking permissions. Can you remove M.norm or find another way for normalizing the path?

thai01255nt avatar Jun 01 '25 17:06 thai01255nt

Same issue for windows 10

shouyierban avatar Jun 04 '25 06:06 shouyierban

Same issue for windows11 23h2 10.0.22631.5335]

wzj-zz avatar Jun 05 '25 00:06 wzj-zz

Unfortunately, AI plugins for nvim are lagging significantly behind the AI capabilities of most other major IDEs.

I tried Avante, CopilotChat, and CodeCompanion, with constant issues, ranging from permission denied, to rate limiting, to diff crashes.

I have now been testing vscode Agent mode for a week, without a single problem (when it comes to agentic AI work).

I wish the above was not the case, but the current difference in quality and stability is substantial, to the point where we are forced to step away from Neovim for AI coding work.

I prefer Neovim in every other way, so hoping it will catch up soon.

magnusriga avatar Jun 06 '25 22:06 magnusriga

I have exactly same thoughts. I'd really hate to give up on the favorite editor because of it.

ekropotin avatar Jun 06 '25 23:06 ekropotin

Me as well. What i have been doing is working with other ides for code generation, and using vin for manual adjustments. My workflow goes like: Ask modifications -> Accept suggestions if they make sense -> perform adjustments in neovim. Separating concerns between code generation and code manual writing has been the best approach imo. But of course, if i could do everything inside neovim it would be better.

felipejoribeiro avatar Jun 09 '25 12:06 felipejoribeiro

Same issue on macos

noahruben-disney avatar Jun 11 '25 19:06 noahruben-disney

I know is not the best solution, but by setting the config in legacy mode the plugin does work; not the best AI flow, but good enough for me tbh (specially combined with autosuggestion).

I really love the plugin, thanks for the effort on fixing this.

Pakas342 avatar Jun 16 '25 03:06 Pakas342

@Pakas342 Could you please tell me how to set this up?

Vladipz avatar Jun 16 '25 07:06 Vladipz

@Vladipz On the config, set mode to 'legacy':

mode = 'legacy',

There's only two modes: . "agentic" uses tools to automatically generate code (the one that causes the issues and comes as default), "legacy" uses the old planning method to generate code.

Pakas342 avatar Jun 17 '25 21:06 Pakas342

only edit files where neovim was started. editing files outside of the project root is blocked. If you want to edit your config files, open neovim in your config directory.

wsbuck avatar Jul 03 '25 18:07 wsbuck

After the update, the agentic mode is now working back again on my machine

Pakas342 avatar Jul 07 '25 23:07 Pakas342

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 12 '25 02:08 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Aug 23 '25 02:08 github-actions[bot]

in my case, i didn't expect that avante will fail to read or update files ignored in git with "No permission to access path".

aimestereo avatar Nov 22 '25 08:11 aimestereo