yetone / avante.nvim

Use your Neovim like using Cursor AI IDE!
Apache License 2.0
5.78k stars 195 forks source link

curl: (23) Failed writing received data to disk/application #315

Closed dbarrosop closed 1 month ago

dbarrosop commented 1 month ago

Hello, I am trying this plugin which looks very promising but after setting it up I am getting the following error:

- Datetime: 2024-08-28 13:03:05

- Model: claude/claude-3-5-sonnet-20240620

> hello

🔄 **Generating response ...**

🚨 Error: {
  exit = 23,
  message = 'post https://api.anthropic.com/v1/messages - curl error exit_code=23 stderr={ "curl: (23) Failed writing received data to disk/application" }',
  stderr = '{ "curl: (23) Failed writing received data to disk/application" }'
}

Looks like curl is trying to write something to disk and doesn't have permissions. I tried changing the setting history.storage_path but same issue. Do you know what this plugin is trying to write to disk, where and how to change it?

In case it helps I am running this on MacOS and I installed neovim using nix and looks like using sudo works (which confirms it is a permission issue I guess).

Thanks!

MathieuTuli commented 1 month ago

+1

aarnphm commented 1 month ago

what curl version are you using? there was an issue about curl 8.7 or sth similar afaik.

MathieuTuli commented 1 month ago

I had seen that, I just tried updating to 8.9.1 but no change. I had 8.1.2 before and the issue persisted.

Note I used to use my own simple llm plugin and use curl just fine in a very similar manner to this plugin, so I know with reasonable confidence it's not curl (version), unless there's specific piping going on that is obfuscated. Will dig further.

dbarrosop commented 1 month ago

I am using curl 8.7.1 but in my case if I start nvim with sudo it works fine so I suspect it is a permissions issue. Is the history the only thing being written to disk? I can see the folder being created but no files written when running nvim, with sudo nvim I can see the history files being written.

scmeek commented 1 month ago

I'm also seeing this issue. I'm using openai and have confirmed curling requests outside of neovim & avante work as expected. I tried updating curl as well and am still seeing the issue.

dbarrosop commented 1 month ago

Seems related https://github.com/nvim-lua/plenary.nvim/issues/536

MathieuTuli commented 1 month ago

@dbarrosop from what I gather the command fails before even getting to the history save, so I don't think that's it. Permissions on the state folder defined by storage_path seem okay so I don't think it's a permission issue there.

It's the Llm.stream() call that's failing, and falling back to on_error - it would ideal to get a print out of the exact curl command so I could test/see what may be going on. I suspect it may be from trying to stream the curl response, which is perhaps piping data to another command this permission error.

dbarrosop commented 1 month ago

Ok, I think I figured it out. So the issue is that the curl method is using $XDG_RUNTIME_DIR, which in my case was set to /run/user/501 which didn't exist. Just for the sake of trying I tried to set it to /tmp/run/user/501 but same issue. Finally, I created the folder with mkdir -p /tmp/run/user/501 and now everything works.

MathieuTuli commented 1 month ago

@dbarrosop yeah it seems plenary on MacOs, or some set of config, causes it to look there instead of the default /tmp. This also works as a fix.

export XDG_RUNTIME_DIR="/tmp/"

Which you can set in your .zshrc or something. I recommend doing this as folders in /tmp are not guaranteed to be persistent.

This is most likely a plenary issue.

dbarrosop commented 1 month ago

I ended up setting it to $TMPDIR as I am using nix and my $TMPDIR is actually different from /tmp.

In any case, maybe this can be closed.

Thanks a lot for the help and the plugin.

scmeek commented 1 month ago

@dbarrosop yeah it seems plenary on MacOs, or some set of config, causes it to look there instead of the default /tmp. This also works as a fix.

export XDG_RUNTIME_DIR="/tmp/"

Which you can set in your .zshrc or something. I recommend doing this as folders in /tmp are not guaranteed to be persistent.

This is most likely a plenary issue.

This worked for me as well.

aarnphm commented 1 month ago

I wil reference this into the wiki. will close it as it doesn't seem like it is related to the plugin.