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

bug: tmux with 'sensibleOnTop' option no longer uses the correct shell #5952

Open
2 tasks done
cixel opened this issue Oct 10, 2024 · 12 comments
Open
2 tasks done

bug: tmux with 'sensibleOnTop' option no longer uses the correct shell #5952

cixel opened this issue Oct 10, 2024 · 12 comments
Assignees
Labels
bug triage Issues or feature request that have not been triaged yet

Comments

@cixel
Copy link

cixel commented Oct 10, 2024

Are you following the right branch?

  • My Nixpkgs and Home Manager versions are in sync

Is there an existing issue for this?

  • I have searched the existing issues

Issue description

The upstream version of tmux was updated last week to 3.5a (commit). One of the changes in this version (from 3.5) is that /bin/sh is used for run-shell.

With this version of tmux, all panes/windows/etc use sh instead of the configured default shell (in my case, zsh).

My rough guess is that this change in tmux has introduced some ordering issues when sensibleOnTop is set, as run-shell will now use sh regardless of how tmux's default-shell is set.

The problem goes away if I do:

  package = pkgs.tmux.overrideAttrs (old: rec {
    version = "3.5";
    src = pkgs.fetchFromGitHub {
      owner = "tmux";
      repo = "tmux";
      rev = version;
      hash = "sha256-8CRZj7UyBhuB5QO27Y+tHG62S/eGxPOHWrwvh1aBqq0=";
    };
  });

or if I set sensibleOnTop = false;

Maintainer CC

@jorsn @rycee (cc based on a7cdfaa).

System information

- system: `"aarch64-darwin"`
 - host os: `Darwin 23.6.0, macOS 14.7`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - channels(ehdens): `"home-manager, nixpkgs"`
 - nixpkgs: `/Users/ehdens/.nix-defexpr/channels/nixpkgs`
@cixel cixel added bug triage Issues or feature request that have not been triaged yet labels Oct 10, 2024
@x123
Copy link

x123 commented Oct 13, 2024

I'm also experiencing the same issue. The notes for tmux 3.5a here tmux/tmux#4162 say the following:

"Note that a fix in 3.5 and 3.5a to correctly set SHELL for run-shell and if-shell reveals a bug in the tmux-sensible script, causing it to set default-shell to /bin/sh. This can be worked around by adding this to .tmux.conf after the tmux-sensible script is invoked:"

 - system: `"aarch64-darwin"`
 - host os: `Darwin 24.0.0, macOS 15.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source`

EDIT: Using the following in extraConfig to make sure it's run after tmux-sensible loads seems to fix the issue on darwin and is the updated recommendation from tmux/tmux#4162 (comment)

set -gu default-command
set -g default-shell "$SHELL"

@gshpychka
Copy link

gshpychka commented Oct 14, 2024

Same here. Having set -g default-shell "$SHELL" as the last line in my tmux.conf does not fix the issue, only disabling the sensible plugin by setting sensibleOnTop to false does.

EDIT: using set -g default-command "$SHELL" does fix the issue on darwin (with the sensible plugin enabled)

michaelvanstraten added a commit to michaelvanstraten/systems that referenced this issue Oct 18, 2024
Yash-Garg added a commit to Yash-Garg/dotfiles that referenced this issue Oct 20, 2024
totallyGreg added a commit to totallyGreg/home that referenced this issue Oct 22, 2024
tmux sensible uses this if it's found and this causes problems with
default-command being set to sh instead of zsh
see: tmux/tmux#4162 and
nix-community/home-manager#5952 which provided
the correct workaround of setting default-command to $SHELL
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tmux-use-bash-instead-defined-zsh-in-home-manager/54763/2

YorikSar added a commit to YorikSar/dotfiles that referenced this issue Oct 30, 2024
tmux now calls run-shell with /bin/sh, which causes tmux-sensible use it
instead of my shell here:
https://github.com/tmux-plugins/tmux-sensible/blob/master/sensible.tmux#L103

Hardcode `/bin/zsh` instead of `$SHELL` there, since I know what I want
to use.

Issues:
home-manager: nix-community/home-manager#5952
tmux: tmux/tmux#4162
@YorikSar
Copy link
Contributor

Quick and (very) dirty workaround for this:

  nixpkgs.overlays = [
    (final: prev: {
      tmuxPlugins = prev.tmuxPlugins // {
        sensible = prev.tmuxPlugins.sensible.overrideAttrs (prev: {
          postInstall = prev.postInstall + ''
            sed -e 's:\$SHELL:/bin/zsh:g' -i $target/sensible.tmux
          '';
        });
      };
    })
  ];

It hardcodes /bin/zsh (replace it with what you like to use) and rebuilds tmux-sensible with it.

@art1es23
Copy link

art1es23 commented Nov 12, 2024

I'm also experiencing the same issue. The notes for tmux 3.5a here tmux/tmux#4162 say the following:

"Note that a fix in 3.5 and 3.5a to correctly set SHELL for run-shell and if-shell reveals a bug in the tmux-sensible script, causing it to set default-shell to /bin/sh. This can be worked around by adding this to .tmux.conf after the tmux-sensible script is invoked:"

 - system: `"aarch64-darwin"`
 - host os: `Darwin 24.0.0, macOS 15.0.1`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.18.8`
 - channels(root): `"nixpkgs"`
 - nixpkgs: `/nix/store/60sn02zhawl3kwn0r515zff3h6hg6ydz-source`

EDIT: Using the following in extraConfig to make sure it's run after tmux-sensible loads seems to fix the issue on darwin and is the updated recommendation from tmux/tmux#4162 (comment)

set -gu default-command
set -g default-shell "$SHELL"

This solved the root problem, but after running tmux I got another issue:
/Users/qmpwwsd/.config/tmux/tmux.conf:91: not a suitable shell: zsh
Screenshot 2024-11-12 at 11 33 21

After pressing the 'Enter' key:

  • if this is a new session: zsh is used
  • if the session is saved: all panels use bash by default, not zsh, only after closing the panel and opening it again zsh is used. So I need to reopen every time all panes which I saved

And I don't know how to fix it

@zoriya
Copy link

zoriya commented Nov 12, 2024

SHELL needs to be an absolute path, not a binary name. You'd need to set it to something like /run/current-system/sw/bin/zsh

@gen740
Copy link

gen740 commented Nov 13, 2024

I encountered the same issue, and at that time, I noticed that home-manager's tmux automatically loads the sensible plugin.
I love having plentiful options, but is it necessary to load this plugin by default?

@gshpychka
Copy link

I encountered the same issue, and at that time, I noticed that home-manager's tmux automatically loads the sensible plugin. I love having plentiful options, but is it necessary to load this plugin by default?

It's supposed to be a sensible default, hence the name ;)

@gen740
Copy link

gen740 commented Nov 13, 2024

It’s supposed to be a sensible default, hence the name ;)

This is simply the origin of the plugin’s name. Regardless of the name, it’s still just a plugin.

Who would expect that setting tmux.enable = true would also load an additional tmux plugin?

@gen740
Copy link

gen740 commented Nov 13, 2024

And unfortunately, it seems that tmux-sensible is no longer being maintained...

tmux-plugins/tmux-sensible#70 (comment)

alesauce added a commit to alesauce/nix-home that referenced this issue Nov 14, 2024
@gshpychka
Copy link

It’s supposed to be a sensible default, hence the name ;)

This is simply the origin of the plugin’s name. Regardless of the name, it’s still just a plugin.

Who would expect that setting tmux.enable = true would also load an additional tmux plugin?

I don't disagree, was mostly joking.

Yeah, considering the last commit was over 2 years ago - could be worth considering changing the default.

@gen740
Copy link

gen740 commented Nov 15, 2024

Are there any problems in creating the PR on this?

I think a bit more discussion is needed, but it is inconvenient to discuss in this thread.

gen740 added a commit to gen740/home-manager that referenced this issue Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug triage Issues or feature request that have not been triaged yet
Projects
None yet
Development

No branches or pull requests