Skip to content

Add Debian terminfo directory default to find_terminfo_file #51809

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

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

christiangnrd
Copy link
Contributor

@christiangnrd christiangnrd commented Oct 21, 2023

Without this, Base.current_terminfo returns TermInfo(String[]; 0 flags, 0 numbers, 0 strings) because it cannot find the correct terminfo files. In the regular terminal, there was basic color and formatting functionality because $TERMs starting with xterm are treated specially, but in a tmux session, where the $TERM = tmux-256color, there was no color at all.

This also has the side-effect of enabling strikethrough and italics in the default gnome terminal emulator.

The readme found in /etc/terminfo/README (as mentioned in terminfo(5) "Fetching Compiled Descriptions") says the following:

/etc/terminfo/README 
This directory is for system-local terminfo descriptions. By default,
ncurses will search ${HOME}/.terminfo first, then /etc/terminfo (this
directory), then /lib/terminfo, and last not least /usr/share/terminfo.

I believe the manual might be different depending on the distro.

@christiangnrd
Copy link
Contributor Author

I don't seem to have the permissions to officially request a review so I'm tagging @tecosaur in this comment.

@maleadt maleadt requested a review from tecosaur October 21, 2023 17:22
Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add the full list from that README too

@tecosaur
Copy link
Member

tecosaur commented Oct 21, 2023

In principle, I don't see anything wrong with this, but I'm curious where /lib/terminfo and /etc/terminfo/README are coming from?

On my system, if I run man 'terminfo(5)' I don't see any reference to that README file (which doesn't exist for me), and I can't see it on https://www.man7.org/linux/man-pages/man5/terminfo.5.html either 😕.

@christiangnrd
Copy link
Contributor Author

I think we should add the full list from that README too

I originally didn't add /etc/terminfo to the list because it was empty (except for the README) but I think you're right. Change made.

The rest is already handled by the function.

@tecosaur
Copy link
Member

/etc/terminfo is also considered in #51198. Actually, I'm wondering if we could maybe merge that first/instead? If we're going to get more PRs to terminfo.jl it would be better if they build off that refactored version.

@christiangnrd
Copy link
Contributor Author

@tecosaur What distro are you on? On Debian (raspberrypiOS) and Ubuntu 23.04, the manual has the following:

   Fetching Compiled Descriptions
       The  ncurses  library  searches  for  terminal  descriptions in several places.  It uses only the first description
       found.  The library has a compiled-in list of places to search which can be overridden  by  environment  variables.
       Before starting to search, ncurses eliminates duplicates in its search list.

       •   If  the  environment  variable TERMINFO is set, it is interpreted as the pathname of a directory containing the
           compiled description you are working on.  Only that directory is searched.

       •   If TERMINFO is not set, ncurses will instead look in the directory $HOME/.terminfo for a compiled description.

       •   Next, if the environment variable TERMINFO_DIRS is set, ncurses will interpret the contents of that variable as
           a list of colon-separated directories (or database files) to be searched.

           An empty directory name (i.e., if the variable begins or ends with a colon, or contains adjacent colons) is in‐
           terpreted as the system location /etc/terminfo.

       •   Finally, ncurses searches these compiled-in locations:

           •   a list of directories (no default value), and

           •   the system terminfo directory, /etc/terminfo (the compiled-in default).

@tecosaur
Copy link
Member

I'm on opensuse, but I can't see the README mentioned on my NixOS server either, or:

which has me thinking this could be a "debian special"?

@christiangnrd
Copy link
Contributor Author

Probably is. The readme is also missing from CentOS 8.

@christiangnrd
Copy link
Contributor Author

@tecosaur I'll rebase once #51198 is merged.

@laborg
Copy link
Contributor

laborg commented Oct 23, 2023

In principle, I don't see anything wrong with this, but I'm curious where /lib/terminfo and /etc/terminfo/README are coming from?

The files in /lib/terminfo are provided by the debian package ncurses-base which, at least on ubuntu, is an "essential system-critical" (according to apt) package.

@imciner2
Copy link
Contributor

which has me thinking this could be a "debian special"?

It isn't. The lack of these specified in the man page is because the terminfo directories can be specified as build time options.

For instance, the build configs of several distros are:

Debian:

--with-terminfo-dirs="/etc/terminfo:/lib/terminfo:/usr/share/terminfo" \

Fedora:

--with-terminfo-dirs=%{_sysconfdir}/terminfo:%{_datadir}/terminfo \

OpenSUSE:

--with-terminfo-dirs=%{_sysconfdir}/terminfo:%{_datadir}/terminfo \

Nix:

"--with-terminfo-dirs=${lib.concatStringsSep ":" [
  "/etc/terminfo" # Debian, Fedora, Gentoo
  "/lib/terminfo" # Debian
  "/usr/share/terminfo" # upstream default, probably all FHS-based distros
  "/run/current-system/sw/share/terminfo" # NixOS
]

@christiangnrd
Copy link
Contributor Author

Rebased now that #51198 is merged. I tested it and it's able to find the tmux terminfo file on debian so ready to merge after review and/or passing tests.

@christiangnrd
Copy link
Contributor Author

Test failure is unrelated

@KristofferC KristofferC merged commit 2b939f7 into JuliaLang:master Feb 8, 2024
@christiangnrd christiangnrd deleted the terminfo-dirs branch November 30, 2024 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants