Terminal program displays garbage using ncurses

#1

So I’m on a system that only has an old broken version of ncurses 5 available, and I’d like to use nix to build the kakoune editor with ncurses 6. I can do this fairly easily with just nix-shell -p ncurses or nix-shell '<nixpkgs>' -A kakoune since there is a kakoune package in nixpkgs. I’m not really sure how the nixpkgs version works because I have to modify the Makefile to have ncurses instead of ncursesw.

But when I do this, kakoune runs, but displays garbage, like ~U ~T~@ ~T~@ in the info box instead of the nice lines it normally does. The same thing happens when I run the version from nixpkgs nix-shell -p kakoune --run kak.

Any ideas? I’ve been trying to figure this out for a while with absolutely no success.

#2

It’s hard to know without a bit more details.

What else can you tell about the base operating system? What distribution and version is it running?

Can you also run nix-shell -p nix-info --run "nix-info -m" and paste the result?

Finally, can you try and run nix-shell --pure -p kakoune --run kak and report if you are seeing the same issues?

Hopefully that will be enough to starting finding some clues.

#3

Some curses stuff has problems in some terminals for me (lately); you may try the same in plain xterm, in case that is the problem…

#4

This bit is also quite interesting, I am not aware of a type of encoding that would produce this type of output.

#5

Not the OP but seeing exactly the same issue. Running it with nix-shell --pure ... doesn’t seem to make a difference.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.14.55, NixOS, 18.03.132865.411cc559c05 (Impala)`
 - multi-user?: `yes`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.4`
 - channels(root): `"nixos-18.03.132865.411cc559c05"`
 - channels(daniel): `"nixpkgs-18.09pre149607.b9fafcfc302"`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs`
#6

So NixOS 18.03 as a base system and then using the nixos-unstable channel to run curses.

I don’t have a system with 18.03 installed right now to test this out. Anyone else?

#7

I can reproduce this on my 18.03 using nix-shell -I nixpkgs=channel:nixos-unstable -p kakoune --run kak. However, the issue seems to be specific to kakoune — nix-shell -I nixpkgs=channel:nixos-unstable -p ncdu --run ncdu works fine.

#8

I installed it as well withnix from the latest nixpkgs-unstable on ubuntu 16.04 and I see the same issue. Does it work if you try it on your system? If you run it with kak you should see a pop-up with a changelog and you can see the broken output there already (it is a sort of vim clone, so you then exit with “:q” :))

#9

I get the same problem with nix-shell -I nixpkgs=channel:nixos-16.09, (though you have to go find the info box, it doesn’t show at startup that far back) and that’s as far back as the kakoune package goes. I haven’t yet found any version or way to build kakoune with nix that works properly.

$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 4.9.0-6-amd64, Debian GNU/Linux, noversion`
 - multi-user?: `no`
 - sandbox: `no`
 - version: `nix-env (Nix) 2.0.4`
 - channels(mattpeterson): `"nixpkgs-18.09pre147700.03e47c388ac"`
 - nixpkgs: `/home/mattpeterson/.nix-defexpr/channels/nixpkgs`

So, I mentioned having to replace ncursesw with ncurses in the Makefile to get it to build. One interesting tidbit is that if I do that, and then build kakoune without nix I end up with a similar problem, though the corruption is a bit different: M-b~UM--M-b etc.

ncdu works fine for me, but doesn’t seem to use the fancy unicode characters that Kakoune is using, so I’m not sure that’s true. Kakoune works and displays fine other than the unicode characters in the info box.

#10

I have also encountered the same problem, although only with the latest version on the unstable channel. The one on the stable branch seems fine wrt display characters, although it (besides being older) has a very annoying bug that causes it to crash if you enter a % at the command prompt.

I am not sure what it is. Talking to people on the #kakoune and #nixos IRC channels, I though that somehow ncurses that kakoune was did not have wide character support, but I do not think that is the case.

#11

The box that pops up when you press i (in ncdu) uses unicode box-drawing characters.

#12

I’ve still got that problem on Ubuntu 18.04.

If I do

nix-shell '<nixpkgs>' -A kakoune

and manually change the Makefile to link against the system’s ncursesw it works just fine.

  • system: "x86_64-linux"
  • host os: Linux 4.15.0-39-generic, Ubuntu, 18.04.1 LTS (Bionic Beaver)
  • multi-user?: no
  • sandbox: yes
  • version: nix-env (Nix) 2.2
  • channels(user): "nixpkgs-19.09pre173097.84903aa3545"
  • nixpkgs: /home/user/.nix-defexpr/channels/nixpkgs

Has anyone solved it?

#13

It works fine for me if I link against ncurses-6.1-20190112-abi5-compat.

#14

It actually didn’t work. I somehow convinced bash to execute a different kak from $(which kak) which made me believe it works.

Anyway: I’ve found the issue and the libc does not find the locales. Can be fixed with nix-env -i glibc-locales. If I then source the nix-support/setup-hook of that package kakoune runs fine.

How do I make this into a runtime dependency of kakoune, so that it is sourced automatically if kakoune is part of my user environment?