Error while installing home-manager

Hello,
After testing Nix package manager on my gentoo system, I wanted to give home-manager a try.

When installing it, I’ve got an error that I don’t know how to solve :

thomas@gentoo ~ % nix-shell '<home-manager>' -A install
Creating /home/thomas/.config/home-manager/home.nix...

Creating initial Home Manager generation...

/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/string_view:239: constexpr const std::basic_string_view<_CharT, _Traits>::value_type& std::basic_string_view<_CharT, _Traits>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; const_reference = const char&; size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
/nix/store/50pc8chr8y7hfrr9213ifi30a8c7r9yi-home-manager/bin/home-manager: line 509:  2718 Aborted                 nix-build "<home-manager/home-manager/home-manager.nix>" "${extraArgs[@]}" "${PASSTHROUGH_OPTS[@]}" --argstr confPath "$HOME_MANAGER_CONFIG" --argstr confAttr "$HOME_MANAGER_CONFIG_ATTRIBUTE"
Uh oh, the installation failed! Please create an issue at

    https://github.com/nix-community/home-manager/issues

if the error seems to be the fault of Home Manager.

Version being installed :

thomas@gentoo ~ % /nix/store/50pc8chr8y7hfrr9213ifi30a8c7r9yi-home-manager/bin/home-manager --version
23.11-pre

I don’t know whether there could be an issue with gcc or home-manager here.

Do you know what went wrong here ?

Thank you in advance

Thomas

Due to the fact that there are non store paths in that error message, my assumption is, that you have some LD_* env-var set that confuses the dynamic linker and nix is loaded with the wrong dynamic libraries.

This is just a very blind shot though.

Hello @NobbZ

Thank you for your reply.

I don’t know exactly what to check here.

I’m not aware of any specific LD_* environment variables :

thomas@gentoo ~ % env | grep LD_
thomas@gentoo ~ % su -
gentoo ~ # env | grep LD_
gentoo ~ #

Regarding nix :

thomas@gentoo ~ % ldd /usr/bin/nix
        linux-vdso.so.1 (0x00007ffe92bd8000)
        libnixexpr.so => /usr/lib64/libnixexpr.so (0x00007f2b5f3eb000)
        libatomic_ops.so.1 => /usr/lib64/libatomic_ops.so.1 (0x00007f2b5f3e6000)
        libgc.so.1 => /usr/lib64/libgc.so.1 (0x00007f2b5f2a3000)
        libnixmain.so => /usr/lib64/libnixmain.so (0x00007f2b5f25b000)
        libnixfetchers.so => /usr/lib64/libnixfetchers.so (0x00007f2b5f169000)
        libnixstore.so => /usr/lib64/libnixstore.so (0x00007f2b5edbd000)
        libnixutil.so => /usr/lib64/libnixutil.so (0x00007f2b5ec67000)
        libnixcmd.so => /usr/lib64/libnixcmd.so (0x00007f2b5eb87000)
        libstdc++.so.6 => /usr/lib/gcc/x86_64-pc-linux-gnu/12/libstdc++.so.6 (0x00007f2b5e92d000)
        libgcc_s.so.1 => /usr/lib/gcc/x86_64-pc-linux-gnu/12/libgcc_s.so.1 (0x00007f2b5e90d000)
        libc.so.6 => /lib64/libc.so.6 (0x00007f2b5e738000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f2b5f998000)
        libboost_context.so.1.82.0 => /usr/lib64/libboost_context.so.1.82.0 (0x00007f2b5e733000)
        libm.so.6 => /lib64/libm.so.6 (0x00007f2b5e656000)
        libsqlite3.so.0 => /usr/lib64/libsqlite3.so.0 (0x00007f2b5e4e2000)
        libcurl.so.4 => /usr/lib64/libcurl.so.4 (0x00007f2b5e448000)
        libsodium.so.23 => /usr/lib64/libsodium.so.23 (0x00007f2b5e3f4000)
        libseccomp.so.2 => /usr/lib64/libseccomp.so.2 (0x00007f2b5e3d4000)
        libcrypto.so.3 => /usr/lib64/libcrypto.so.3 (0x00007f2b5df9d000)
        libbrotlienc.so.1 => /usr/lib64/libbrotlienc.so.1 (0x00007f2b5df0d000)
        libbrotlidec.so.1 => /usr/lib64/libbrotlidec.so.1 (0x00007f2b5df00000)
        libarchive.so.13 => /usr/lib64/libarchive.so.13 (0x00007f2b5de39000)
        libcpuid.so.16 => /usr/lib64/libcpuid.so.16 (0x00007f2b5de15000)
        libeditline.so.1 => /usr/lib64/libeditline.so.1 (0x00007f2b5de09000)
        libicui18n.so.73 => /usr/lib64/libicui18n.so.73 (0x00007f2b5dade000)
        libicuuc.so.73 => /usr/lib64/libicuuc.so.73 (0x00007f2b5d8de000)
        libcares.so.2 => /usr/lib64/libcares.so.2 (0x00007f2b5d8c5000)
        libnghttp2.so.14 => /usr/lib64/libnghttp2.so.14 (0x00007f2b5d894000)
        libssl.so.3 => /usr/lib64/libssl.so.3 (0x00007f2b5d7ef000)
        libz.so.1 => /lib64/libz.so.1 (0x00007f2b5d7d3000)
        libbrotlicommon.so.1 => /usr/lib64/libbrotlicommon.so.1 (0x00007f2b5d7b0000)
        libacl.so.1 => /lib64/libacl.so.1 (0x00007f2b5d7a5000)
        liblzma.so.5 => /lib64/liblzma.so.5 (0x00007f2b5d778000)
        libbz2.so.1 => /lib64/libbz2.so.1 (0x00007f2b5d765000)
        libxml2.so.2 => /usr/lib64/libxml2.so.2 (0x00007f2b5d603000)
        libicudata.so.73 => /usr/lib64/libicudata.so.73 (0x00007f2b5b778000)
thomas@gentoo ~ % cat /etc/ld.so.conf
# ld.so.conf autogenerated by env-update; make all changes to
# contents of /etc/env.d directory
include ld.so.conf.d/*.conf
/usr/lib/OpenCL/vendors/nvidia
/usr/lib64/OpenCL/vendors/nvidia
/lib64
/usr/lib64
/usr/local/lib64
/lib
/usr/lib
/usr/local/lib
/usr/lib64/oracle/client/lib64
/usr/lib/rust/lib
/usr/lib/llvm/16/lib64
/usr/lib/llvm/15/lib64
/usr/lib64/fltk

Nix may have been compiled with an older toolchain. I’m going to recompile it.

Thomas

How did that nix got built? I expect nix to reside in the store, managed and built by “itself” or being a completely static build.

There is also GitHub - trofi/nix-guix-gentoo: Gentoo overlay for nix and guix functional package managers.

Hello,
Yes I installed it through the nix-guix-gentoo overlay. Please note that nix-env works (I was able to install packages).
Recompiling Nix didn’t help.
Thomas

ping @trofi who maintains the overlay

Thanks for the ping! I never tried home-manager before and will need to get up to speed with it. Do you use Home Manager Manual procedure to get it installed?

I did the following and it worked for me:

$ nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
$ nix-channel --update
$ nix-shell '<home-manager>' -A install
$ source $HOME/.nix-profile/etc/profile.d/hm-session-vars.sh
$ home-manager packages
home-manager
shared-mime-info-2.2
man-db-2.11.2
hm-session-vars.sh
man-pages

I think it means it worked. I used gcc-13 locally though. Can you post your emerge --info for completeness? I’ll try on gcc-12 on a host system as well.

Hello,
Thank you for your replies.
I did the same, except that the third command crashed.

Channel list :

thomas@gentoo ~ % nix-channel --list
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixgl https://github.com/guibou/nixGL/archive/main.tar.gz
nixpkgs https://nixos.org/channels/nixpkgs-unstable

emerge --info as well :

thomas@gentoo ~ % emerge --info
Mot de passe :
Portage 3.0.49 (python 3.11.4-final-0, default/linux/amd64/17.1/desktop/plasma, gcc-12, glibc-2.37-r3, 5.4.251 x86_64)
=================================================================
System uname: Linux-5.4.251-x86_64-Intel-R-_Core-TM-_i5-2500K_CPU_@_3.30GHz-with-glibc2.37
KiB Mem:    20484448 total,  19539060 free
KiB Swap:    2064380 total,   2064380 free
Timestamp of repository gentoo: Mon, 14 Aug 2023 14:30:01 +0000
Head commit of repository gentoo: eb74343862e3e39ea6ccfbce3db9110b3aff92df
Head commit of repository guru: 530bea0d351f643cccc9330709c0f7d0ab38ae9d

Head commit of repository kde: a057fb0156b20fa844579de863e04d56fcb4f74c

Head commit of repository mozilla: 7f09fc95b402bdbfaee8156bda2187bdbf634018

Head commit of repository nix-guix: 3156f23adbc7b87d3a6255ee2010421e7267cd42

Head commit of repository torbrowser: c82acb3f72903f22a4aabb50fb2b84bac9099d74

sh bash 5.1_p16-r6
ld GNU ld (Gentoo 2.40 p5) 2.40.0
ccache version 4.8.2 [disabled]
app-misc/pax-utils:        1.3.5::gentoo
app-shells/bash:           5.1_p16-r6::gentoo
dev-java/java-config:      2.3.1-r1::gentoo
dev-lang/perl:             5.36.1-r3::gentoo
dev-lang/python:           3.11.4::gentoo
dev-lang/rust-bin:         1.69.0-r1::gentoo
dev-util/ccache:           4.8.2::gentoo
dev-util/cmake:            3.26.4-r2::gentoo
dev-util/meson:            1.1.1::gentoo
sys-apps/baselayout:       2.13-r1::gentoo
sys-apps/openrc:           0.47.1::gentoo
sys-apps/sandbox:          2.37::gentoo
sys-devel/autoconf:        2.71-r6::gentoo
sys-devel/automake:        1.16.5-r1::gentoo
sys-devel/binutils:        2.40-r5::gentoo
sys-devel/binutils-config: 5.5::gentoo
sys-devel/clang:           15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/gcc:             12.3.1_p20230526::gentoo
sys-devel/gcc-config:      2.11::gentoo
sys-devel/libtool:         2.4.7-r1::gentoo
sys-devel/lld:             15.0.7::gentoo, 16.0.6::gentoo
sys-devel/llvm:            15.0.7-r3::gentoo, 16.0.6::gentoo
sys-devel/make:            4.4.1-r1::gentoo
sys-kernel/linux-headers:  6.1::gentoo (virtual/os-headers)
sys-libs/glibc:            2.37-r3::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.gentoo.org/gentoo-portage
    priority: -1000
    volatile: True
    sync-rsync-extra-opts:
    sync-rsync-verify-metamanifest: yes
    sync-rsync-verify-jobs: 1
    sync-rsync-verify-max-age: 24

x-portage
    location: /usr/local/portage
    masters: gentoo
    priority: 0
    volatile: True

guru
    location: /var/lib/layman/guru
    sync-type: git
    sync-uri: https://anongit.gentoo.org/git/repo/proj/guru.git
    masters: gentoo
    priority: 50
    volatile: True

kde
    location: /var/lib/layman/kde
    sync-type: git
    sync-uri: https://github.com/gentoo/kde.git
    masters: gentoo
    priority: 50
    volatile: True

mozilla
    location: /var/lib/layman/mozilla
    sync-type: git
    sync-uri: git://anongit.gentoo.org/proj/mozilla.git
    masters: gentoo
    priority: 50
    volatile: True

nix-guix
    location: /var/lib/layman/nix-guix
    sync-type: git
    sync-uri: https://github.com/trofi/nix-guix-gentoo.git
    masters: gentoo
    priority: 50
    volatile: True

torbrowser
    location: /var/lib/layman/torbrowser
    sync-type: git
    sync-uri: https://github.com/MeisterP/torbrowser-overlay.git
    masters: gentoo
    priority: 50
    volatile: True

Binary Repositories:

binhost
    priority: 9999
    sync-uri: https://gentoo.osuosl.org/experimental/amd64/binpkg/default/linux/17.1/x86-64

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="@FREE"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O2 -pipe"
DISTDIR="/var/tmp/distfiles"
EMERGE_DEFAULT_OPTS="--binpkg-respect-use=y --getbinpkg=y"
ENV_UNSET="CARGO_HOME DBUS_SESSION_BUS_ADDRESS DISPLAY GDK_PIXBUF_MODULE_FILE GOBIN GOPATH PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR XDG_STATE_HOME"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-docompress binpkg-dostrip binpkg-logs buildpkg buildpkg-live config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync metadata-transfer multilib-strict network-sandbox news parallel-fetch pid-sandbox preserve-libs protect-owned qa-unresolved-soname-deps sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS="http://distfiles.gentoo.org"
LANG="fr_FR.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed -Wl,--hash-style=gnu -Wl,-z,now"
LEX="flex"
LINGUAS="fr fr_FR"
MAKEOPTS="-j5"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --exclude=/.git"
PORTAGE_TMPDIR="/var/tmp"
SHELL="/bin/bash"
USE="3dnow 3dnowext X a52 aac acl acpi activities alsa amd64 avahi avx bash-completion branding bzip2 cairo cdda cddb cdio cdr cli crypt cups dbus declarative dri dts dvb dvd dvdr elogind encode exif ffmpeg flac fortran gcj gdbm gif glibc-omitfp gphoto2 gpm gui hardened iconv icu ipv6 java6 jpeg kde kdeenablefinal kdehiddenvisibility kipi kwallet libnotify libtirpc live mad mmx mmxext mng mp3 mp4 mpeg multilib musepack musicbrainz ncurses nls nptl nptlonly ogg openmp pam pango pcre pdf plasma png policykit ppds qml qt5 readline samba seccomp sound spell split-usr sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 startup-notification svg test-rust theora tiff truetype udev udisks unicode upower usb v4l v4l2 vdpau vorbis vulkan wayland widgets wxwidgets x264 xattr xcb xft xinerama xml xv xvid zlib" ABI_X86="64" ADA_TARGET="gnat_2021" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="karbon sheets words" CAMERAS="canon" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="sse sse2 3dnow 3dnowext mmx mmxext avx ssse3 sse3 sse4_1 sse4_2" CURL_SSL="openssl" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock greis isync itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf skytraq superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" L10N="fr" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LUA_SINGLE_TARGET="lua5-1" LUA_TARGETS="lua5-1" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php8-1" POSTGRES_TARGETS="postgres15" PYTHON_SINGLE_TARGET="python3_11" PYTHON_TARGETS="python3_11" RUBY_TARGETS="ruby31" SANE_BACKENDS="hp" VIDEO_CARDS="amdgpu radeonsi r300" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq proto steal rawnat logmark ipmark dhcpmac delude chaos account"
Unset:  ADDR2LINE, AR, ARFLAGS, AS, ASFLAGS, CC, CCLD, CONFIG_SHELL, CPP, CPPFLAGS, CTARGET, CXX, CXXFILT, ELFEDIT, EXTRA_ECONF, F77FLAGS, FC, GCOV, GPROF, INSTALL_MASK, LC_ALL, LD, LFLAGS, LIBTOOL, MAKE, MAKEFLAGS, NM, OBJCOPY, OBJDUMP, PORTAGE_BINHOST, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, RANLIB, READELF, RUSTFLAGS, SIZE, STRINGS, STRIP, YACC, YFLAGS

Aha! The configuration looks sensible. Looking at your initial assert I thing it triggers an assertion in one of your libraries (or nix itself):

/usr/lib/gcc/x86_64-pc-linux-gnu/12/include/g++-v12/string_view:239: constexpr const std::basic_string_view<_CharT, _Traits>::value_type& std::basic_string_view<_CharT, _Traits>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; const_reference = const char&; size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.

I think it’s a side-effect of this gentoo-specific patch in gcc that enables _GLIBCXX_ASSERTIONS on all USE=hardened gcc users: https://github.com/gentoo/gcc-patches/blob/d0b55776a4e1d2f293db5ba0e4a04aefed055ec4/12.3.0/gentoo/15_all_DEF_GENTOO_GLIBCXX_ASSERTIONS.patch

We need to find which library triggers that assert. Try to extract the nix-build command as is when it’s ran from home-manger script. (Maybe bash -x` is ehough?) and then try to get a backtrace from the crash. I would try to do something like:

$ gdb --args nix-build ....
gdb> start
...
gdb> break __glibcxx_assert_fail
gdb> continue
gdb> bt
...

Maybe we’ll find that last crash that brings your program down.

Chances are it’s a nix bug. Triggered on nix git tree as:

--- a/Makefile
+++ b/Makefile
@@ -47,4 +47,4 @@ endif

 include mk/lib.mk

-GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++2a -I src
+GLOBAL_CXXFLAGS += -g -Wall -include config.h -std=c++2a -I src -D_GLIBCXX_ASSERTIONS
$ nix build .#
warning: Git tree '/mnt/archive/big/git/nix' is dirty
error: builder for '/nix/store/zis6gz3lpvjqnff8rycm2hbjwzsly4jm-nix-2.18.0pre20230814_dirty.drv' failed with exit code 2;
       last 10 log lines:
       > [       OK ] SearchPathElem.parse_twoEqs (0 ms)
       > [ RUN      ] SearchPathElem.suffixIfPotentialMatch_justPath
       > [       OK ] SearchPathElem.suffixIfPotentialMatch_justPath (0 ms)
       > [ RUN      ] SearchPathElem.suffixIfPotentialMatch_misleadingPrefix1
       > [       OK ] SearchPathElem.suffixIfPotentialMatch_misleadingPrefix1 (0 ms)
       > [ RUN      ] SearchPathElem.suffixIfPotentialMatch_misleadingPrefix2
       > [       OK ] SearchPathElem.suffixIfPotentialMatch_misleadingPrefix2 (0 ms)
       > [ RUN      ] SearchPathElem.suffixIfPotentialMatch_partialPrefix
       > /nix/store/1gf2flfqnpqbr1b4p4qz2f72y42bs56r-gcc-11.3.0/include/c++/11.3.0/string_view:234: constexpr const value_type& std::basic_string_view<_CharT, _Traits>::operator[](std::basic_string_view<_CharT, _Traits>::size_type) const [with _CharT = char; _Traits = std::char_traits<char>; std::basic_string_view<_CharT, _Traits>::const_reference = const char&; std::basic_string_view<_CharT, _Traits>::size_type = long unsigned int]: Assertion '__pos < this->_M_len' failed.
       > make: *** [mk/lib.mk:120: libexpr-tests_RUN] Aborted (core dumped)
       For full logs, run 'nix log /nix/store/zis6gz3lpvjqnff8rycm2hbjwzsly4jm-nix-2.18.0pre20230814_dirty.drv'.

Reported as: https://github.com/NixOS/nix/issues/8824

1 Like

Thank you trofi for digging into this issue that quickly :slight_smile:

And thanks for raising this issue!

If you are feeling brave try the =sys-apps/nix-2.17-r1 from the overlay with a trivial fix: sys-apps/nix: pull search-path OOB fix pending upstream inclusion · trofi/nix-guix-gentoo@0d114d4 · GitHub

It did not break things for me. But I wonder if there are more asserts hiding around.

I just installed nix-2.17-r1, which allowed to install home-manager properly.

Thank you again for your help!

1 Like

Hi folks, I’m new to nix, how can I install an old version of nix? I’m having a similar issue and wanna try the 2.17 version

Are you sure you are running into the same problem? Do you also use ::nix-guix overlay with hardened options enabled for gcc?

If you do the simplest workaround would be to use CXXFLAGS=-U_GLIBCXX_ASSERTIONS as a workaround for nix packages.

And better yet would be to update to latest ebuilds that already have it fixed.