wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
16.67k stars 745 forks source link

WSL - `default_cwd` UNC path only works in the first tab opened #5503

Open gsuuon opened 3 months ago

gsuuon commented 3 months ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20240520-135708-b8f94c47

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When default_cwd is an UNC path like //wsl.localhost/Ubuntu-22.04/home/gsuuon from wslpath -am ~ and default_prog is wsl, the first time opening wezterm the cwd is set but the second attempt seems to strip the leading / and error.

To Reproduce

  1. start wezterm with below config (replacing distro/username)
  2. open another tab

Configuration

return {
  default_prog = { 'wsl' },
  default_cwd = '//wsl.localhost/Ubuntu-22.04/home/gsuuon'
}

Expected Behavior

Can open multiple tabs at default_cwd

Logs

22:31:39.537  WARN   mux::domain > Directory "/wsl.localhost/Ubuntu-22.04/home/gsuuon/" is not readable and will not be used for the command we are spawning: The system cannot find the path specified. (os error 3)

Anything else?

This shell is not set to report OSC 7, though maybe it's pulling the path some other way?

I tried with a non-~ path and see the same behavior. Also tried with ///wsl.localhost.. and that errors the first time and fails to set cwd the second.

I tried with return { default_domains = 'WSL:Ubuntu-22.04' } and that seems to have the same issue, where the first tab opens to ~ within wsl and the second opens to /mnt/c/Users/gsuuon (on Windows) but there's no error.

bladezcode commented 1 month ago

@gsuuon try adding cd ~ in your .bashrc or shell youre using by default

bladezcode commented 1 month ago

using config.default_cwd didnt work too, still a noob on configuring wezterm lol

marzeq commented 1 month ago

Same here, launching the first window puts me in ~ (and if I change the home for my user in WSL it correctly reflects that), but any other new spawned pane always opens in /mnt/c/Users/<username>

Relevant part of my config for reference:

local use_wsl = true

if string.find(wezterm.target_triple, "windows") and use_wsl then
  local wsl_domains = wezterm.default_wsl_domains()
  c.wsl_domains = wsl_domains

  if #wsl_domains > 0 then
    local default_distro_name = "arch"
    local found = false

    for _, domain in ipairs(wsl_domains) do
      if string.find(domain.name, default_distro_name) then
        c.default_domain = domain.name
        found = true
        break
      end
    end

    -- fallback to the first distro
    if not found then
      c.default_domain = wsl_domains[1].name
    end
  end
end