diff --git a/codec/src/lib.rs b/codec/src/lib.rs index 65a96a952..af9b17f59 100644 --- a/codec/src/lib.rs +++ b/codec/src/lib.rs @@ -26,6 +26,7 @@ use smol::prelude::*; use std::convert::TryInto; use std::io::Cursor; use std::ops::Range; +use std::path::PathBuf; use std::sync::Arc; use termwiz::hyperlink::Hyperlink; use termwiz::surface::{Line, SequenceNo}; @@ -401,7 +402,7 @@ macro_rules! pdu { /// The overall version of the codec. /// This must be bumped when backwards incompatible changes /// are made to the types and protocol. -pub const CODEC_VERSION: usize = 11; +pub const CODEC_VERSION: usize = 12; // Defines the Pdu enum. // Each struct has an explicit identifying number. @@ -536,6 +537,8 @@ pub struct GetCodecVersion {} pub struct GetCodecVersionResponse { pub codec_vers: usize, pub version_string: String, + pub executable_path: PathBuf, + pub config_file_path: Option, } #[derive(Deserialize, Serialize, PartialEq, Debug)] diff --git a/wezterm-client/src/client.rs b/wezterm-client/src/client.rs index 436e15ea8..144274644 100644 --- a/wezterm-client/src/client.rs +++ b/wezterm-client/src/client.rs @@ -946,7 +946,10 @@ impl Client { } } - pub async fn verify_version_compat(&self, ui: &ConnectionUI) -> anyhow::Result<()> { + pub async fn verify_version_compat( + &self, + ui: &ConnectionUI, + ) -> anyhow::Result { match self.get_codec_version(GetCodecVersion {}).await { Ok(info) if info.codec_vers == CODEC_VERSION => { log::trace!( @@ -954,7 +957,7 @@ impl Client { info.version_string, info.codec_vers ); - Ok(()) + Ok(info) } Ok(info) => { let err = IncompatibleVersionError { diff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rs index 60d3c54d4..18568e7b0 100644 --- a/wezterm-gui/src/main.rs +++ b/wezterm-gui/src/main.rs @@ -434,7 +434,19 @@ impl Publish { let executor = promise::spawn::ScopedExecutor::new(); let command = cmd.clone(); let res = block_on(executor.run(async move { - client.verify_version_compat(&mut ui).await?; + let vers = client.verify_version_compat(&mut ui).await?; + + if vers.executable_path != std::env::current_exe().context("resolve executable path")? { + anyhow::bail!( + "Running GUI is a different executable from us, will start a new one"); + } + if vers.config_file_path + != std::env::var_os("WEZTERM_CONFIG_FILE").map(Into::into) + { + anyhow::bail!( + "Running GUI has different config from us, will start a new one" + ); + } client .spawn_v2(codec::SpawnV2 { domain: config::keyassignment::SpawnTabDomain::DefaultDomain, diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rs index 42d095268..38134f357 100644 --- a/wezterm-mux-server-impl/src/sessionhandler.rs +++ b/wezterm-mux-server-impl/src/sessionhandler.rs @@ -534,10 +534,18 @@ impl SessionHandler { } Pdu::GetCodecVersion(_) => { - send_response(Ok(Pdu::GetCodecVersionResponse(GetCodecVersionResponse { - codec_vers: CODEC_VERSION, - version_string: config::wezterm_version().to_owned(), - }))) + match std::env::current_exe().context("resolving current_exe") { + Err(err) => send_response(Err(err)), + Ok(executable_path) => { + send_response(Ok(Pdu::GetCodecVersionResponse(GetCodecVersionResponse { + codec_vers: CODEC_VERSION, + version_string: config::wezterm_version().to_owned(), + executable_path, + config_file_path: std::env::var_os("WEZTERM_CONFIG_FILE") + .map(Into::into), + }))) + } + } } Pdu::GetTlsCreds(_) => {