Nix develop and tmux: bind: command not found

Hello

This is my flake.nix file:

{
  description = "";

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }:
    flake-utils.lib.eachDefaultSystem (system:
      let pkgs = import nixpkgs { inherit system; };
      in
      {
        devShell = pkgs.mkShell {
          buildInputs = [
            pkgs.go
            pkgs.gopls
            pkgs.redis
            pkgs.redis-dump
          ];
        };
      });
}

And when I run:

$ nix develop

and I try to open tmux this is what I get:

bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
bind: command not found
gianarb@dieci \[\]~/git/glue/go\[\]  (main=) $

If i go the other way around and I run nix develop inside a tmux session everything works just line

I don’t have tmux globally installed. I added

pkgs.tmux

to your `buildInputs’

try that, and see what you get.

Hello! Thanks, I get the same error

Try adding pkgs.bashInteractive? (Assuming you use bash.)

I also encountered an issue related to this in the past:

I use bash. I tried to add bashInteractive but it does not work.

I had a look at the links you have shared but I can’t really figure out my problem yet

https://github.com/NixOS/nixpkgs/issues/46876

but there was a work around, perhaps devshells reintroduces the problem.

you on nixos, or just nix on another distro/OSX?

Hello, I am on NixOS

UPDATE (I was wrong): Nix develop and tmux: bind: command not found - #13 by gianarb

I have the solution. I replaced pkgs.mkShell with pkgs.mkShellNoCC and now it works!

1 Like

now i’m even more confused.

Possibly a distraction, but your shell prompt containing escape backslashes is something I have, when I run bash inside a nix develop shell:

…/nix-develop-and-tmux-bind-command-not-found-24029 on  main at 21:14:48 zsh
❯ nix develop

…/nix-develop-and-tmux-bind-command-not-found-24029 on  main via   (nix-shell) at 21:14:50 bsh
❯ bash

\[\]↕\[\]\[\]3\[\] \[\]…/nix-develop-and-tmux-bind-command-not-found-24029\[\] on \[\] \[\]\[\]main\[\] via \[\] \[\]\[\] (\[\]\[\]nix-shell\[\]\[\])\[\] at \[\]21:14:51\[\] \[\]bsh\[\]
\[\]❯\[\]

Running outside of nix develop:

…/nix-develop-and-tmux-bind-command-not-found-24029 on  main took 1m5s at 21:15:56 zsh
❯ bash

…/nix-develop-and-tmux-bind-command-not-found-24029 on  main at 21:15:57 bsh
❯

(note my primary shell is zsh).

Though this happens when I’ve used mkShellNoCC too so likely a different issue.

One question I have is, are you joining an existing tmux session, starting a new tmux session, or does this occur in both? I’ve noticed when I join an existing session on my desktop via ssh from my laptop, and switch clients via ( and ) keys, then go back to my desktop and create a new window via ctrl-C, the $SSH_CONNECTION variable is still set and my shell thinks I’m ssh-ing (the starship prompt makes this obvious).

The reason for this is because while $SSH_CONNECTION wasn’t set in the original client, when I joined it from a new client which had $SSH_CONNECTION set, it inherited it. I can verify this by running tmux show-environment from within a new tmux window from my desktop.

Sorry I’m rambling a bit, question is, how do you open tmux? Are there existing tmux windows/sessions open?

1 Like

If I start tmux and then I run nix develop everything works great.

When I do the opposite, I start nix develop and then I run tmux inside it I get those errors

My bad I was wrong here Nix develop and tmux: bind: command not found - #8 by gianarb

it still does not work

1 Like

Sorry if this is just noise but I had a similar problem with VS Code. Everything else worked well, but code behaved erratically (uninterpreted escape sequences, lots of shopts errors, etc).

I solved my problem by adding a symlink from $HOME/bin/bash to ../.nix-profile/bin/bash. No clue why code was picking up the wrong bash but not other programs (like iTerm).