oflisback / obsidian-bridge.nvim

A neovim plugin used to synchronize active note and scroll position between neovim and obsidian
Other
120 stars 7 forks source link

commands sent to the local rest api from the console work, but not from obsidian-bridge (WSL) #18

Closed HungryTamales closed 3 months ago

HungryTamales commented 3 months ago

Hello @oflisback, thank you for creating such a cool tool, this looks perfect for my workflow, unfortunately I haven't been able to make it work.

I am running nvim from WSL with mirror network configuration, so localhost is the same in windows and linux

this command on the WSL console works curl -X 'POST' \ 'http://127.0.0.1:27123/open/KnowledgeBase/Work/Python.md' \ -H 'accept: */*' \ -H 'Authorization: Bearer '$OBSIDIAN_REST_API_KEY \ -d ''

This means that the ip is correct, the port is open, the server in obsidian is running, the api key is correct, and that sending data between WSL and windows is not a problem

but whenever I change notes in nvim, this is shown post http://127.0.0.1:27123/open/KnowledgeBase/Work/Python.md - curl error exit_code=23 stderr={ "curl: (23) Failed writing received data to disk/application" }

this is my obsidian-bridge.lua in my plugin folder return { "oflisback/obsidian-bridge.nvim", dependencies = { "nvim-telescope/telescope.nvim" }, config = function() require("obsidian-bridge").setup({ scroll_sync = false, obsidian_server_address = "http://127.0.0.1:27123", }) end, event = { "BufReadPre *.md", "BufNewFile *.md", }, lazy = true, }

please let me know if there is other relevant info I should provide thank you for reading through this!

oflisback commented 3 months ago

Hi @HungryTamales, since this works from the WSL console but not from the plugin I think it's best to investigate in the curl wrapper obsidian-bridge uses which is https://github.com/nvim-lua/plenary.nvim/blob/master/lua/plenary/curl.lua.

It would be interesting to compare your command line vs what curl.lua executes, if you have the opportunity, locate your curl.lua and add a debug statement like this:

  print("Executing command: " .. job_opts.command .. " " .. table.concat(job_opts.args, " "))

after this block:

  local job_opts = {
    command = vim.g.plenary_curl_bin_path or "curl",
    args = args,
  }

to see how it differs. I don't use Windows myself and had not heard of the mirrored mode but it sounds pretty neat!

Perhaps this issue has some clue https://github.com/nvim-lua/plenary.nvim/issues/536 too.

HungryTamales commented 3 months ago

@oflisback, thank you very much for your insight!

this was interesting, the command referencing a folder that does not exist, creating the folder fixed the issue /run/user/1000/ a comment on the issue you suggested mentions that this folder wont be created until a graphical session is launched I am assuming that in my case, since I only use the command line in linux, and anything with a GUI happens in windows, the folder was not created.

would it be reasonable to add this to the installation steps as a note for future users?

regardless, thank you very much, I an quite new to using the command line and your help was invaluable.

oflisback commented 3 months ago

Ok nice job glad it worked out! I think it's borderline too much of an edge case for the README but I could be wrong, at least this issue adds to the discoverability.