fix: add first try connection for debug/gitpod workaround
@@ -327,6 +327,25 @@ fn start(
}
fn start_remote(&self, remote: impl Remote) -> Result<()> {
+ // start ssh CM connection in case where it doesn't handle
+ // executing command properly on remote host
+ // also print ssh debug output when used with LAPCE_DEBUG env
+ match remote.command_builder().arg("lapce-no-command").output() {
+ Ok(cmd) => {
+ let stderr = String::from_utf8_lossy(&cmd.stderr).to_lowercase();
+ let stderr = stderr.trim();
+ log::debug!(target: "lapce_data::proxy::start_remote::first_try", "{}", &stderr);
+
+ let stdout = String::from_utf8_lossy(&cmd.stdout).to_lowercase();
+ let stdout = stdout.trim();
+ log::debug!(target: "lapce_data::proxy::start_remote::first_try", "{}", &stdout);
+ }
+ Err(err) => {
+ log::error!(target: "lapce_data::proxy::start_remote::first_try", "{err}");
+ return Err(anyhow!(err));
+ }
+ }
+
use HostPlatform::*;
let (platform, architecture) = self.host_specification(&remote).unwrap();
@@ -516,6 +535,8 @@ fn host_specification(
let stdout = stdout.trim();
log::debug!(target: "lapce_data::proxy::host_platform", "{}", &stdout);
match stdout {
+ // If empty, then we probably deal with Windows and not Unix
+ // or something went wrong with command output
"" => {
let cmd = remote
.command_builder()
@@ -624,6 +645,11 @@ impl SshRemote {
fn command_builder(user: &str, host: &str) -> Command {
let mut cmd = new_command("ssh");
cmd.arg(format!("{}@{}", user, host)).args(Self::SSH_ARGS);
+
+ if !std::env::var("LAPCE_DEBUG").unwrap_or_default().is_empty() {
+ cmd.arg("-v");
+ }
+
cmd
}
}
@@ -757,12 +783,7 @@ fn parse_os(os: &str) -> HostPlatform {
"linux" => Linux,
"darwin" => Darwin,
"windows_nt" => Windows,
- v => {
- if v.ends_with("bsd") {
- Bsd
- } else {
- UnknownOS
- }
- }
+ v if v.ends_with("bsd") => Bsd,
+ _ => UnknownOS,
}
}
