amitds1997 / remote-nvim.nvim

Remote development in Neovim 🔥
MIT License
536 stars 13 forks source link

Job failure when testing connection to remote #157

Open amitds1997 opened 1 month ago

amitds1997 commented 1 month ago

I came across the above problem while trying to debug my main machine which fails on the echo 'Hello' check with the following output:

DEBUG Wed 10 Jul 2024 13:19:24 BST /nix/store/8qvna5qxr8yil5l53lchi9db9r7frfb7-vim-pack-dir/pack/myNeovimPackages/start/remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:866: [ssh][ubuntu-container] Starting remote neovim launch
DEBUG Wed 10 Jul 2024 13:19:24 BST /nix/store/8qvna5qxr8yil5l53lchi9db9r7frfb7-vim-pack-dir/pack/myNeovimPackages/start/remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:141: Did not find any existing configuration. Creating one now..
DEBUG Wed 10 Jul 2024 13:19:24 BST /nix/store/8qvna5qxr8yil5l53lchi9db9r7frfb7-vim-pack-dir/pack/myNeovimPackages/start/remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:995: ["ssh"]["ubuntu-container"] Running "echo 'Hello'"
DEBUG Wed 10 Jul 2024 13:19:25 BST /nix/store/8qvna5qxr8yil5l53lchi9db9r7frfb7-vim-pack-dir/pack/myNeovimPackages/start/remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:1015: ["ssh"]["ubuntu-container"] Running "echo 'Hello'" completed
ERROR Wed 10 Jul 2024 13:19:25 BST /nix/store/8qvna5qxr8yil5l53lchi9db9r7frfb7-vim-pack-dir/pack/myNeovimPackages/start/remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:973: 'Testing remote connection' failed.
stack traceback:
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:974: in function '_handle_job_completion'
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:1017: in function 'run_command'
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:142: in function '_setup_workspace_variables'
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:872: in function '_launch_neovim'
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:883: in function <.../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:882>
    [C]: in function 'xpcall'
    .../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:759: in function <.../remote-nvim.nvim/lua/remote-nvim/providers/provider.lua:758> 

FAILED JOB OUTPUT (SO FAR)
bash: -c: line 1: unexpected EOF while looking for matching `''
bash: -c: line 2: syntax error: unexpected end of file

Which uses OpenSSH_9.8, but since I am going from a NixOS machine to a docker container, there are more than a few moving parts to investigate along the lines of #150 before I feel comfortable opening a new issue. If you have any ideas what might be causing this please let me know!

Originally posted by @TakodaS in https://github.com/amitds1997/remote-nvim.nvim/issues/147#issuecomment-2220992760

amitds1997 commented 1 month ago

Could you please provide a minimal reproducible example for this?

TakodaS commented 1 month ago

As mentioned in #155 the issue is the result of a call to vim.fn.shellescape. Logging the raw command returns "echo 'Hello'" -> "ssh remote 'echo '\\''Hello'\\'''". Running print(vim.fn.shellescape("echo 'Hello'") returns 'echo '\''Hello'\'''

Running the following commands directly from terminal give the following outputs:

ssh remote 'echo '\\''Hello'\\'' -> \\Hello\

ssh remote 'echo '\''Hello'\''' -> [same error as reported]