wez / wezterm

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

Using tmux with wezterm.config_builder() results in failure to apply config overrides or change user vars #5078

Closed winter-again closed 3 months ago

winter-again commented 7 months ago

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

Linux Wayland

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

Sway v1.8.1

WezTerm version

wezterm 20240203-110809-5046fc22 (also tried wezterm 20240221-075452-95581d86 from AUR)

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 using tmux inside of Wezterm along with wezterm.config_builder() to build my config, I'm unable to issue any config overrides or set user variables. Outside of tmux, things work as expected. I made sure to allow passthrough in my tmux conf.

To Reproduce

Specify Wezterm config using wezterm.config_builder(). Start/attach to tmux session. As described in the user vars docs page, every time the prompt is shown I get the error below and Wezterm doesn't respond to user var changes.

Configuration

local wezterm = require('wezterm')
local config = {}
if wezterm.config_builder then
    config = wezterm.config_builder()
end

Expected Behavior

User vars are set and the callback I have set up to respond to user var changes should respond (e.g., change background).

Logs

01:18:38.178 WARN wezterm_gui::termwindow::resize > cannot resize window to match Some(RowsAndCols { rows: 47, cols: 95 }) because window_state is MAXIMIZED 01:18:44.065 ERROR wezterm_gui::termwindow > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: WEZTERM_PROG is not a valid Config field. There are too many alternatives to list here; consult the documentation!) stack traceback: [C]: in metamethod 'newindex'

: {"WEZTERM_PROG": "ls"} 01:18:44.189 ERROR wezterm_gui::termwindow > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: WEZTERM_PROG is not a valid Config field. There are too many alternatives to list here; consult the documentation!) stack traceback: [C]: in metamethod 'newindex'

: {"WEZTERM_PROG": ""} 01:18:44.272 ERROR wezterm_gui::termwindow > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: WEZTERM_PROG is not a valid Config field. There are too many alternatives to list here; consult the documentation!) stack traceback: [C]: in metamethod 'newindex'

: {"WEZTERM_PROG": "ls", "WEZTERM_USER": "andrew"} 01:18:44.359 ERROR wezterm_gui::termwindow > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: WEZTERM_IN_TMUX is not a valid Config field. There are too many alternatives to list here; consult the documentation!) stack traceback: [C]: in metamethod 'newindex'

: {"WEZTERM_IN_TMUX": 1, "WEZTERM_PROG": "ls"} 01:18:44.448 ERROR wezterm_gui::termwindow > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: WEZTERM_HOST is not a valid Config field. There are too many alternatives to list here; consult the documentation!) stack traceback: [C]: in metamethod 'newindex'

: {"WEZTERM_HOST": "winter-again", "WEZTERM_PROG": "ls"}

Anything else?

No response

wez commented 3 months ago

Did you forget to return config at the bottom?

winter-again commented 3 months ago

I did make sure to return config at the bottom. I also made sure I'm sourcing the wezterm.sh shell integration file in my .zshrc and set set -g allow-passthrough on in my tmux.conf (my understanding is that I need both). Just to be clear, user var overrides work fine if I simply initiate local config = {} instead of using config_builder().

I think I can narrow down the logs a bit to make the issue more clear:

22:48:39.897  ERROR  wezterm_gui::termwindow         > Failed to apply config overrides to window: error converting Lua table to Config (Config::from_dynamic: `WEZTERM_IN_TMUX` is not a valid Config field.  There are too many alternatives to list here; consult the documentation!)
stack traceback:
        [C]: in metamethod 'newindex'
        [string "config/src/config.rs:1108:14"]:3: in function <[string "config/src/config.rs:1108:14"]:2>
: {"WEZTERM_IN_TMUX": 1, "background": Array { inner: [{"height": "100%", "opacity": 1, "source": {"Color": "#16161e"}, "width": "100%"}] }}
wez commented 3 months ago

Here's the thing: the config you shared doesn't match the config that is showing up in the error messages. I cannot help you with what you have shared. The issue is that your config file is invalid. The error messages are telling you what the problem is. You need to correct your config file. Are you editing the right config file? See https://wezfurlong.org/wezterm/config/files.html#configuration-files

winter-again commented 3 months ago

I've gotten things working again with my plugin (for sending config overrides from Neovim) and wezterm.config_builder(). This issue can remain closed.

If you're interested: looks like my code that was getting called on the "user-var-changed" event was naively trying to pass the shell integration user vars described here. Of course, those aren't valid config options, hence the errors. Not sure if it's the most clever thing, but manually excluding them from consideration worked.

Thanks again for your hard work on Wezterm. It's a joy to use.

github-actions[bot] commented 2 months ago

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.