mikew / nvrh

Aims to be similar to VSCode Remote, but for Neovim
MIT License
48 stars 0 forks source link

fix: Dont fork ssh #23

Closed mikew closed 1 month ago

mikew commented 1 month ago

In https://github.com/mikew/nvrh/pull/20 I changed the SSH process so it wasn't part of the process group. That was so ctrl-c wouldn't immediately close the SSH process and prevent nvrh from sending a command to the remote neovim instance and close it.

While that works, it also means that the password prompt isn't shown for users that don't have an SSH agent / pubkey auth. Since it only applies to ctrl-c, and I don't even think it works on Windows, I'm fine with disabling it until a better solution is found.

This also switches to slog because I need more logging levels than "print" and "fatal", and adds a --debug flag which shows much more output.

Preview

When --debug is passed

[11:42:20.531] INFO: Starting remote nvim {
  "nvimCommandString": " nvim --headless --listen \"/tmp/nvrh-socket-1728830540\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830540\"",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/ssh_helpers/main.go",
    "function": "nvrh/src/ssh_helpers.BuildRemoteNvimCmd",
    "line": 15
  }
}
Pseudo-terminal will not be allocated because stdin is not a terminal.
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
tput: No value for $TERM and no -T specified
channel 2: open failed: connect failed: open failed
[11:42:22.311] INFO: Connected to nvim {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1.2",
    "line": 171
  }
}
[11:42:22.458] INFO: Starting local editor {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.BuildClientNvimCmd",
    "line": 232
  }
}
2024-10-13 11:42:49.822 neovide[95990:8906209] +[IMKClient subclass]: chose IMKClient_Legacy
2024-10-13 11:42:49.822 neovide[95990:8906209] +[IMKInputSession subclass]: chose IMKInputSession_Legacy
[11:42:53.394] INFO: Local editor exited {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1.2",
    "line": 197
  }
}
[11:42:53.395] INFO: Closing nvrh {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.init.func1",
    "line": 214
  }
}
[11:42:53.395] INFO: Closing nvim {
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.closeNvimSocket",
    "line": 369
  }
}
[11:42:53.395] ERROR: Error closing remote nvim {
  "err": "msgpack/rpc: session closed",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.closeNvimSocket",
    "line": 371
  }
}
[11:42:53.395] DEBUG: Killing command {
  "cmd": [
    "ssh",
    "-L",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540:/tmp/nvrh-socket-1728830540",
    "-t",
    "vscode-remote",
    "$SHELL -i -c ' nvim --headless --listen \"/tmp/nvrh-socket-1728830540\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830540\"'"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 355
  }
}
[11:42:53.395] DEBUG: Killing command {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830540"
  ],
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 355
  }
}
[11:42:53.395] ERROR: Error killing command {
  "err": "os: process already finished",
  "source": {
    "file": "/Users/mike/Work/nvrh/src/client/main.go",
    "function": "nvrh/src/client.killAllCmds",
    "line": 358
  }
}

Without --debug

[11:43:32.096] INFO: Starting remote nvim {
  "nvimCommandString": " nvim --headless --listen \"/tmp/nvrh-socket-1728830612\" --cmd \"cd Work/nvrh-demo-app\"; [ true = true ] \u0026\u0026 rm -f \"/tmp/nvrh-socket-1728830612\""
}
[11:43:33.827] INFO: Connected to nvim
[11:43:33.962] INFO: Starting local editor {
  "cmd": [
    "/Applications/Neovide.app/Contents/MacOS/neovide",
    "--server",
    "/var/folders/09/gc_fhm_97csc0w2hlb2wmq_80000gn/T/nvrh-socket-1728830612"
  ]
}
[11:43:45.095] INFO: Local editor exited
[11:43:45.095] INFO: Closing nvrh
[11:43:45.095] INFO: Closing nvim
[11:43:45.095] ERROR: Error closing remote nvim {
  "err": "msgpack/rpc: session closed"
}
[11:43:45.095] ERROR: Error killing command {
  "err": "os: process already finished"
}