diff --git a/docs/changelog.md b/docs/changelog.md index 45532859d..0bdb8fce2 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -83,6 +83,7 @@ As features stabilize some brief notes about them will accumulate here. * Synthesized bold didn't kick in for automatically computed `font_rules`. [#2074](https://github.com/wez/wezterm/issues/2074) * Added [freetype_pcf_long_family_names](config/lua/config/freetype_pcf_long_family_names.md) option to workaround PCF font naming issues on certain Linux distributions. [#2100](https://github.com/wez/wezterm/issues/2100) * X11/Wayland: wezterm.desktop now specifies `StartupWMClass`. Thanks to [@uncomfyhalomacro](https://github.com/uncomfyhalomacro)! [#2052](https://github.com/wez/wezterm/issues/2052) [#2125](https://github.com/wez/wezterm/pull/2125) +* `sudo -i` in a pane would cause subsequent pane/tab creation to fail until the cwd was changed to an accessible directory [#2120](https://github.com/wez/wezterm/issues/2120) ### 20220408-101518-b908e2dd diff --git a/mux/src/domain.rs b/mux/src/domain.rs index 2a0fdeab2..1ff2e3979 100644 --- a/mux/src/domain.rs +++ b/mux/src/domain.rs @@ -254,7 +254,15 @@ impl LocalDomain { // can be painful; in the case where a tab is local but has connected // to a remote system and that remote has used OSC 7 to set a path // that doesn't exist on the local system, process spawning can fail. - if !std::path::Path::new(&dir).exists() { + // Another situation is `sudo -i` has the pane with set to a cwd + // that is not accessible to the user. + if let Err(err) = std::path::Path::new(&dir).read_dir() { + log::warn!( + "Directory {:?} is not readable and will not be \ + used for the command we are spawning: {:#}", + dir, + err + ); cmd.clear_cwd(); } } diff --git a/mux/src/lib.rs b/mux/src/lib.rs index fcade7ff8..1e433eda0 100644 --- a/mux/src/lib.rs +++ b/mux/src/lib.rs @@ -1100,7 +1100,15 @@ impl Mux { }, ); - let tab = domain.spawn(size, command, cwd, window_id).await?; + let tab = domain + .spawn(size, command.clone(), cwd.clone(), window_id) + .await + .with_context(|| { + format!( + "Spawning in domain `{}`: {size:?} command={command:?} cwd={cwd:?}", + domain.domain_name() + ) + })?; let pane = tab .get_active_pane()