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

bug: read_file wrong path

Open BhasherBEL opened this issue 9 months ago • 2 comments

Describe the bug

When I open neovim within a subfolder of a git rep, avante will "lost" a part of the path for the file.

To reproduce

  • Use a git repo at /tmp/repo
  • Go to a subfolder (/tmp/repo/example)
  • Open nvim there on a file /tmp/repo/example/file.
  • Use Avante and the read_file tool.
  • It will drop a part of the path: /tmp/repo/file and warn the the file doesn't exist. (the path within the git repo is lost)

Expected behavior

The full correct path should be used, even when not at the root of the repo.

Installation method

NixOS & NixVim:

programs.nixvim = {
  ...
  plugins = {
    ...
    avante = {
      enable = true;
      settings = {
        claude = {
          api_key_name = "cmd:cat /run/secrets/api/anthropic";
          model = "claude-3-7-sonnet-20250219";
          disable_tools = true;
        };
      };
    };
  };
};

Environment

NVIM v0.10.4 Build type: Release LuaJIT 2.1.1713773202 Linux laptop 6.12.11 #1-NixOS SMP PREEMPT_DYNAMIC Thu Jan 23 16:23:05 UTC 2025 x86_64 GNU/Linux

Repro


BhasherBEL avatar Mar 03 '25 10:03 BhasherBEL

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 Apr 03 '25 02:04 github-actions[bot]

The issue is still there

BhasherBEL avatar Apr 03 '25 06:04 BhasherBEL

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 May 20 '25 02:05 github-actions[bot]

‌You can set this option to true to solve the problem: https://github.com/yetone/avante.nvim/blob/ef61ba52c0117512a0dfecfaa6392d578de62a87/lua/avante/config.lua#L387

yetone avatar May 20 '25 03:05 yetone

Thank you for your reply. Your solution seems to work but imo doesn't solve the real issue. I din't see why it doesn't work the same way when adding a file and when actually reading it.

BhasherBEL avatar May 21 '25 06:05 BhasherBEL