-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
installed terminfo does not load correctly when logging in to a zsh user over ssh #19785
Comments
Probably the issue is unrelated to ssh. I use zsh as my default shell and I get the same error (although for different terminal) when I run |
I think, I got it. The problem is that I added this to environment.sessionVariables = {
TERMINFO_DIRS = "/run/current-system/sw/share/terminfo";
}; And it works now. I'm not quite certain how to proceed with pull request since I don't understand the purpose of |
It seems that zsh handles updates to TERMINFO correctly, but not to TERMINFO_DIRS. I have submitted a patch to zsh to handle that correctly @ http://www.zsh.org/mla/workers/2016/msg02361.html That being said, I could not find why bash handles this correctly. There is no mention of TERMINFO_DIRS in its code source... weird. |
Could you bisect the change that triggered this ? |
Bisecting gives [d2dab39] "ncurses: 5.9 -> 6.0" as the culprit. Looking further, it seems that ncurses comes with its own terminfo database that includes rxvt-256colors but not xrvt-unicode-256colors. I can only assume that it used to be smart enough to fallback to rxvt-256color. The release notes for ncurses 6.0 indicate that the terminfo interface has be reworked, maybe dropping this fallback logic. |
@pschuprikov What is the terminal you use and that causes trouble with |
Thank you for working on this problem! Yes, *rxvt-unicode-256colors *is the ср, 9 нояб. 2016 г. в 17:25, Guillaume Maudoux [email protected]:
|
@pschuprikov, @Ralith: Could you try to |
Hi guys, just wanted to say that I also get this but that the workaround on the comment above works for me. I'm also using |
Hi @unode, thanks for reporting. Could you also check that this setup does not break other terminal emulators while enabled ? Do xterm and gnome-terminal still work correctly for you ? (It works for me, but better check twice). |
@layus 2cfe735 should bring in your zsh change. Is that expected to fix it? I can test it next time I rebase on master, if nobody else has already. I have to be honest that I don't really understand why the zsh change would fix it. Are the system environment variables (including |
@layus I can't identify any issue with this set system-wide. |
FYI, ncurses is a shared lib, and share exactly the same process as the shell. Now, if you rely on your shell to setup TERMINFO* vars to get proper curses interaction with your terminal emulator, it is already too late because curses looks at the environment of the shell itself. To make curses pick the right config, you need either to have that config already setup before the shell starts (solutions 1 and 2) or make the shell update its own process environment (solutions 3) and reinitialize curses data structures. I think 2 is best, even if I started with 3 (I pushed changes to zsh and fish) before realizing that a solution that requires updating any single shell is not viable. 2 is really the way to go, but it can never hurt to have 3, for us and for other distros.
|
@unode Thanks ! Feel free to submit a PR to the manual before me :-D. |
@layus fwiw, this is still broken on 17.03, which does seem to have zsh 5.3.1. It should go without saying that you shouldn't need to manually bodge symlinks to get a non-broken login shell. |
Why ? What makes you expect this ? NixOS uses env vars to pass the terminfo database location. These variables are sourced by the shell. These variables are therefore not in the shell environment when it starts. To get this working, you need special handling in the shell, which is not perfect yet. In your non-workring shell, try to From
Pick your own fix. |
It's not acceptable for reasonable usage to be broken out of the box.
Why not set
It's a fine workaround, but a workaround is not a fix. |
@Ralith see #26897 for a fix with terminfo packages installed globally. This should work for you. For the general case, there is a bug/race condition in zsh, which make my above patch not working in practice. See http://www.zsh.org/mla/workers/2017/msg01035.html |
@Ralith After a two-day marathon chasing the bug in Zsh, I found that ncurses has incorrect caching of env vars, making it ignore our I have submitted a patch upstream, and may consider inserting it into nixpkgs directly (see below) You will need to apply the patch only to zsh's ncurses, otherwise you will end up with a mass-rebuild ;-). Cheers ! diff --git a/ncurses/tinfo/db_iterator.c b/ncurses/tinfo/db_iterator.c
index 94a4082047..0549dae224 100644
--- a/ncurses/tinfo/db_iterator.c
+++ b/ncurses/tinfo/db_iterator.c
@@ -92,33 +92,33 @@ check_existence(const char *name, struct stat *sb)
* Store the latest value of an environment variable in my_vars[] so we can
* detect if one changes, invalidating the cached search-list.
*/
static bool
update_getenv(const char *name, DBDIRS which)
{
bool result = FALSE;
if (which < dbdLAST) {
char *value;
+ char *cached_value = my_vars[which].value;
+ bool same_value;
- if ((value = getenv(name)) == 0 || (value = strdup(value)) == 0) {
- ;
- } else if (my_vars[which].name == 0 || strcmp(my_vars[which].name, name)) {
- FreeIfNeeded(my_vars[which].value);
- my_vars[which].name = name;
- my_vars[which].value = value;
- result = TRUE;
- } else if ((my_vars[which].value != 0) ^ (value != 0)) {
- FreeIfNeeded(my_vars[which].value);
- my_vars[which].value = value;
- result = TRUE;
- } else if (value != 0 && strcmp(value, my_vars[which].value)) {
+ if ((value = getenv(name)) != 0) {
+ value = strdup(value);
+ }
+ same_value = (value == 0 && cached_value == 0)
+ || (value != 0 && cached_value != 0 && strcmp(value, cached_value) == 0);
+
+ // Update var name for later checks
+ my_vars[which].name = name;
+
+ if (!same_value) {
FreeIfNeeded(my_vars[which].value);
my_vars[which].value = value;
result = TRUE;
} else {
free(value);
}
}
return result;
}
|
That does indeed work! I still feel like having the environment set up before the shell starts is more natural, but I don't feel strongly, especially since it sounds like zsh upstream intends to have this functionality. Thanks for all your efforts! |
@Ralith wrote:
Well, there is no other way to make this work for normal users without nixup or something similar. We want users installing terminfo files in their profile to be able to access them. Setting these env vars before the shell starts is tricky, because the shell is the one responsible for setting env vars. Anyway, the patch landed upstream, and the related PR was opened @ #28334 \o/ |
Bump version to include a patch that fixes NixOS#19785.
It's worth noting that this is solvable; either exec a fresh shell after setting things, or set the environment variables with a non-shell mechanism, e.g. by calling |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/error-with-terminfo-when-running-bash-with-nix-run-on-nixos/5660/1 |
Issue description
On login,
/nix/store/yw76cfca2rnhjm68zdf74sy9jwfv2rfy-set-environment:39: can't find terminal definition for xterm-termite
is printed and the terminal is not fully functional. Rerunning the failed command,export TERM=$TERM
, restores the terminal to full functionality despiteTERMINFO_DIRS
not having changed from the value it's set to earlier in that script.Letting the default shell default to
bash
works around the issue.Steps to reproduce
zsh
as the default shell and installtermite.terminfo
inenvironment.systemPackages
.Technical details
The text was updated successfully, but these errors were encountered: