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

nix-shell should either preserve TERMINFO and TERM or neither #1056

Open
bennofs opened this issue Sep 8, 2016 · 10 comments
Open

nix-shell should either preserve TERMINFO and TERM or neither #1056

bennofs opened this issue Sep 8, 2016 · 10 comments
Assignees
Labels

Comments

@bennofs
Copy link
Contributor

bennofs commented Sep 8, 2016

Right now, nix-shell will inherit $TERM from the environment, even if --pure is used. However, it does not preserve the value of $TERMINFO, which leads to a situation where $TERM is set to an invalid value in the inner shell. So either:

  • inherit both $TERMINFO and $TERM
  • do not inherit either $TERMINFO or $TERM (perhaps set $TERM = xterm? that seems to work most of the cases)

Example:

I have $TERM set to rxvt-unicode-256color on my system, with $TERMINFO being /nix/store/dj4m8kaylm598bsybri8vkw3a8mv447m-rxvt-unicode-with-perl-with-unicode3-9.22-terminfo/share/terminfo, which provides the terminfo file for that $TERM value. If I now use nix-shell, weird effects occur like a double prompt or backspace not working correctly, because $TERM is inherited but $TERMINFO is not, so bash no longer finds the terminfo file for that $TERM value.

@bennofs
Copy link
Contributor Author

bennofs commented Sep 8, 2016

In case anyone is looking for a workaround, on NixOS you can add the following to your ~/.bashrc to make the nix-shell use the terminfo database from the system:

if [ -n "$IN_NIX_SHELL" ]; then
  export TERMINFO=/run/current-system/sw/share/terminfo

  # Reload terminfo
  real_TERM=$TERM; TERM=xterm; TERM=$real_TERM; unset real_TERM
fi

@langston-barrett
Copy link
Contributor

langston-barrett commented Oct 25, 2016

I can reproduce this error on Nix 1.11.4. Using zsh, I found this to be a suitable workaround:

nix-shell . --pure --run "export TERM=xterm; zsh"

@copumpkin
Copy link
Member

cc @shlevy @domenkozar @edolstra

@shlevy
Copy link
Member

shlevy commented Feb 26, 2017

Seems reasonable to me.

@edolstra
Copy link
Member

I guess we should also preserve TERMINFO_DIRS.

@unode
Copy link
Member

unode commented Nov 1, 2017

Unsetting TERM works for me.

...until I run into some software that relies on TERM.

@stale
Copy link

stale bot commented Feb 15, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Feb 15, 2021
@bew
Copy link
Contributor

bew commented Feb 15, 2021

I marked this as stale due to inactivity. → More info

This is a new comment

@stale stale bot removed the stale label Feb 15, 2021
@egasimus
Copy link

egasimus commented Aug 5, 2021

So that's why my shells act weird sometimes. Huh.

@stale
Copy link

stale bot commented Apr 17, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Apr 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

9 participants