Error with terminfo when running bash with nix run on NixOS

I’m trying to run bash with nix run on NixOS.

I’m using a command like this:

$ nix run nixpkgs.bash

I end up with a mostly-working bash, but some things are not working, like ansi-escape sequences and keyboard arrow keys.

In my normal bash login shell, I have a bash prompt that looks like the following:

me@my-hostname /some/path $

However, when I am the shell from nix run nixpkgs.bash, the ansi escape sequences don’t look like they are quite working. Here is what it looks like:

\[\]me\[\]@\[\]my-hostname \[\]/some/path \[\]$ \[\]

Also, when I am in the shell from nix run nixpkgs.bash, pressing an arrow key produces an escape on the screen like ^[[C, ^[[B, ^[[D, or ^[[A.

I assume this is a problem with terminfo, but I can’t figure out what could be going on. In both my normal shell, and my shell under nix run, I have the two environment variables set:


I’ve found the following thread talking about problems with terminfo stuff, but none of the solutions seemed to do anything for me (which makes sense, since it is about zsh…):

I should add that I don’t see this problem with nix-shell -p bash (although this is somewhat expected, since nix run and nix-shell are pretty different).

Also, here is my ~/.bashrc file, although I don’t think it is particularly related:

edit: Oh, and this is all on nixos-19.09:

  • system: "x86_64-linux"
  • host os: Linux 4.19.84, NixOS, 19.09.1300.08e503bac6d (Loris)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.3
  • channels(root): "nixos-19.09.1300.08e503bac6d"
  • channels(illabout): "unstable-20.03pre202088.e89b21504f3"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

remember there’s a difference between bash and bashInteractive package.

Ah, that makes sense :slight_smile: Thanks!

This worked as expected:

$ nix run nixpkgs.bashInteractive

In case anyone finds this and is interested in what is going on, bash and bashInteractive are defined similarly in all-packages.nix:

If the bash derivation gets passed the interactive flag, it gets compiled with readline support: