Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set default_cwd on windows #2090

Closed
ackerr opened this issue Jun 7, 2022 · 6 comments
Closed

How to set default_cwd on windows #2090

ackerr opened this issue Jun 7, 2022 · 6 comments

Comments

@ackerr
Copy link

ackerr commented Jun 7, 2022

I want the default pwd is wsl's $HOME when wezterm start,but it always the windows $HOME.

And i find the default_cwd config,set it to other path like C:\Users\Ackerr\.config\wezterm,but it's not work, always the $HOME(C:\Users\Ackerr). And i use this command wezterm start --cwd C:\Users\Ackerr\.config\wezterm,it's not work too.

the minimum config

return {
    default_domain = "WSL:Arch",
    default_prog = { "wsl.exe" },
}

wezterm version

❯ wezterm --version
wezterm 20220408-101518-b908e2dd
@SuperSandro2000
Copy link
Sponsor Contributor

I am currently facing a similar issue where default_cwd is only honored on the first tab, not new tabs. That was on a nightly from 02. June. I just updated to wezterm 20220605-223126-4776c8d9 and now have the same error as ackerr.

relevant config:

local wezterm = require("wezterm")

-- see https://wezfurlong.org/wezterm/config/lua/wezterm/target_triple.html for values
local is_linux = wezterm.target_triple == "x86_64-unknown-linux-gnu"
local is_windows = wezterm.target_triple == "x86_64-pc-windows-msvc"

local wsl_domains = wezterm.default_wsl_domains()

for idx, dom in ipairs(wsl_domains) do
  if dom.name == "WSL:NixOS" then
    dom.default_cwd = "/home/nixos"
  end
end

return {
  default_domain = is_windows and "WSL:Ubuntu" or nil,
  default_prog = is_windows and { "wsl.exe" } or nil,
  hide_tab_bar_if_only_one_tab = false,
  launch_menu = is_windows and { { args = { "cmd.exe" }, domain = { DomainName = "local" } } } or nil,
  set_environment_variables = {
    TERMINFO_DIRS = "/home/" .. (os.getenv("USERNAME") or os.getenv("USER")) .. "/.nix-profile/share/terminfo",
    WSLENV = "TERMINFO_DIRS",
    prompt = is_windows and "$E]7;file://localhost/$P$E\\$E[32m$T$E[0m $E[35m$P$E[36m$_$G$E[0m " or nil,
  },
  -- term = "wezterm",
  wsl_domains = wsl_domains,
}

@ackerr
Copy link
Author

ackerr commented Jun 7, 2022

@SuperSandro2000 I find the wsl_domains config.

And this config work for me.

local wsl_domains = wezterm.default_wsl_domains()

for _, dom in ipairs(wsl_domains) do
    dom.default_cwd = "~"
end

return {
    wsl_domains = wsl_domains,
    default_domain = "WSL:Arch",
    default_prog = { "wsl.exe" },
}

@ackerr
Copy link
Author

ackerr commented Jun 7, 2022

But when i use command to start wezterm,it show this log and the wezterm window is stuck.

❯ wezterm start --cwd ~
22:33:54.522  INFO   wezterm_mux_server_impl::local > setting up C:\Users\Ackerr\.local/share/wezterm\gui-sock-21804
22:33:54.523  INFO   wezterm_client::discovery::windows > published gui path as gui-sock-21804
22:33:54.559  WARN   window::os::windows::window        > EGL init failed Config says to avoid EGL, fall back to WGL
22:33:54.646  INFO   wezterm_gui::termwindow            > OpenGL initialized! NVIDIA GeForce RTX 3070/PCIe/SSE2 4.5.0 NVIDIA 511.79 is_context_loss_possible=true wezterm version: 20220408-101518-b908e2dd`

@wez
Copy link
Owner

wez commented Jun 8, 2022

I just pushed a fix for #2092 which could also be influencing what you're seeing here; it can certainly confuse things.
Could you both give that a try once it is available in the nightly build? It should be there within about an hour from now.

@wez
Copy link
Owner

wez commented Jun 8, 2022

I think what @SuperSandro2000 was seeing was more #2092 than this issue.

@ackerr: your comment in #2090 (comment) is what I'd suggest for the issue you originally describe. The behavior when spawning is to use the normal default_cwd resolution logic, then pass that to the spawned program. wsl.exe will use that cwd when it starts, so if you need it to resolve something from inside the wsl domain, then you'll need to override it explicitly as you have in that config.

@ackerr ackerr closed this as completed Jun 13, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Feb 4, 2023

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants