Skip to content

ncurses is unusable in ld.so.cache (buildFHSUserEnv) #218534

Open

Description

@viric

Describe the bug

When we want a FHS User Env we often want to be able to run commands without LD_LIBRARY_PATH. That requires ldconfig, like buildFHSUserEnvBubblewrap.
But ldconfig builds ld.so.cache only by looking at the declared soname in so objects.

Therefore, the tricks in the ncurses expression to save space (symlinks of postFixup) break this; therefore those ncurses libraries only work through LD_LIBRARY_PATH.

Also, the --with-termlib is required if we want libtinfo.so.5 without the symlink tricks.

Steps To Reproduce

Try to use ncurses in a buildFHSUserEnvBubblewrap without using LD_LIBRARY_PATH.

Expected behavior

The ncurses libs are found. That includes libtinfo.so.5 (requires the not provided --with-termlib in expression).

Additional context

I'm using a FHSUserEnv to build lineageos.

Notify maintainers

@edolstra @vcunat ?

Metadata

[user@system:~]$ nix-shell -p nix-info --run "nix-info -m"
 - system: `"x86_64-linux"`
 - host os: `Linux 5.15.91, NixOS, 22.11 (Raccoon), 22.11beta-297654.gfedcba`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.11.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Activity

  1. added
    0.kind: bug
    on Feb 27, 2023
  2. changed the title [-]ncurses5 is unusable in ld.so.cache (buildFHSUserEnv)[/-] [+]ncurses is unusable in ld.so.cache (buildFHSUserEnv)[/+] on Feb 27, 2023
  3. viric commented on May 27, 2023

    @viric
    MemberAuthor

    Any guidance how to proceed?

    I have to use a nixpkgs local patch to overcome this:

    diff --git a/pkgs/development/libraries/ncurses/default.nix b/pkgs/development/libraries/ncurses/default.nix
    index 2cfe41956a4..b376f127ae3 100644
    --- a/pkgs/development/libraries/ncurses/default.nix
    +++ b/pkgs/development/libraries/ncurses/default.nix
    @@ -8,6 +8,7 @@
     , withCxx ? !stdenv.hostPlatform.useAndroidPrebuilt
     , mouseSupport ? false, gpm
     , unicodeSupport ? true
    +, postFix ? true
     }:
     
     stdenv.mkDerivation rec {
    @@ -38,6 +39,7 @@ stdenv.mkDerivation rec {
         ++ lib.optional (!withCxx) "--without-cxx"
         ++ lib.optional (abiVersion == "5") "--with-abi-version=5"
         ++ lib.optional stdenv.hostPlatform.isNetBSD "--enable-rpath"
    +    ++ lib.optional (!postFix) "--with-termlib"
         ++ lib.optionals stdenv.hostPlatform.isWindows [
           "--enable-sp-funcs"
           "--enable-term-driver"
    @@ -93,7 +95,7 @@ stdenv.mkDerivation rec {
       # When building a wide-character (Unicode) build, create backward
       # compatibility links from the the "normal" libraries to the
       # wide-character libraries (e.g. libncurses.so to libncursesw.so).
    -  postFixup = let
    +  postFixup = if !postFix then "" else let
         abiVersion-extension = if stdenv.isDarwin then "${abiVersion}.$dylibtype" else "$dylibtype.${abiVersion}"; in
       ''
         # Determine what suffixes our libraries have
    

    Then I call pkgs.buildFHSUserEnvBubblewrap with this:

        multiPkgs = pkgs: with pkgs; [
          zlib
          (ncurses5.override {unicodeSupport = true; postFix = false; })
          (ncurses5.override {unicodeSupport = false; postFix = false; })
    
  4. nixos-discourse commented on Nov 20, 2023

    @nixos-discourse

    This issue has been mentioned on NixOS Discourse. There might be relevant details there:

    https://discourse.nixos.org/t/fhs-env-for-installing-xilinx/13150/22

  5. added
    2.status: stale
    on Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bug2.status: stale

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions