[Nix-dev] weird garbage output inside nix-shell

Roni Choudhury aichoudh at gmail.com
Wed Jun 14 23:13:49 CEST 2017


I use the plain old terminal vim, but you inspired me to start probing
whether one of those libraries was specifically causing the problem.

It turns out to be `glibc` that was causing the trouble. I have no idea why
I thought I needed glibc in my nix-shell environment but there you go. If I
omit that one line from my `shell.nix` then everything seems to work ok.

Sergiu, thanks again for engaging with me and diving into this issue, it's
much appreciated!

roni

On Wed, Jun 14, 2017 at 4:58 PM Sergiu Ivanov <sivanov at colimite.fr> wrote:

> Hey Roni,
>
> Thus quoth  Roni Choudhury  at 20:55 on Tue, Jun 13 2017:
> > On Sun, Jun 11, 2017 at 5:45 AM Sergiu Ivanov sivanov at colimite.fr
> > <http://mailto:sivanov@colimite.fr> wrote:
> > Thus quoth  Roni Choudhury  at 17:38 on Sat, Jun 10 2017:
> >>
> > Definitely weird then - is there some way to probe exactly what packages
> > are in my nix-shell environment? Do I do that just by following symlinks
> > eventually into the store?
>
> There are probably some more intelligent ways of doing that, but I don't
> know of them :-(
>
> >> If I send my shell.nix, would someone else mind trying to use it to see
> if
> >> > you can reproduce my strange results?
> >>
> >> Go ahead.  (Remember to scrub all sensitive information.)
> >>
> > Thank you. I’ve attached my shell.nix file to this message.
>
> I have no trouble running vim inside the environment provided by your
> shell.nix.  I get no extra messages.
>
> However, when I try running termite, gedit, or gimp, I get error
> messages similar to yours.  I suppose your vim command launches gvim,
> which uses GTK, just like gedit and gimp.  Note that I don't have issues
> with qutebrowser, which does not use GTK.
>
> > I did discover that I can “fix” my shell problems by omitting this line
> > from shell.nix:
> >
> > LD_LIBRARY_PATH = stdenv.lib.makeLibraryPath libs;
> >
> > Without that line, my LD_LIBRARY_PATH env var just has
> > /run/opengl-driver/lib in it, and vim works as expected. I’m not sure
> why I
> > did this, because my build seems to work without it.
>
> Omitting this line fixes the issues on my machine as well.  Moreover, if
> I take your original shell.nix (with redefined LD_LIBRARY_PATH), run
> nix-shell and manually set LD_LIBRARY_PATH to /run/opengl-driver/lib, or
> even to the _empty string_, things work as expected.
>
> > This may explain why my ldd output differs inside and outside my
> > nix-shell environment.
>
> I didn't observe any differences for any of the applications I tried,
> but I didn't look really hard.
>
> > So I guess my next question is: if I did want to put those packages’
> > libraries into my library loader path, how am I supposed to do it? I
> tried
> > this:
> >
> > LD_LIBRARY_PATH = "$LD_LIBRARY_PATH:${stdenv.lib.makeLibraryPath libs}";
> >
> > but that doesn’t work for, perhaps, obvious reasons.
>
> One way of doing this would be just moving that line into shellHook
> (mind the spaces around the equals sign):
>
>   shellHook = ''
>     LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${stdenv.lib.makeLibraryPath libs}"
>     echo "Candela nix dev environment"
>   '';
>
> The way you tried it originally doesn't work because, apparently, Nix
> does not apply shell variable expansion.
>
> If you tried writing something like this, outside of shellHook,
>
>   LD_LIBRARY_PATH = "${LD_LIBRARY_PATH}:${stdenv.lib.makeLibraryPath lib}";
>
> you probably saw that LD_LIBRARY_PATH is undefined.  I think that's
> because the environment variable LD_LIBRARY_PATH is not defined (or is
> not accessible via a Nix variable) at this stage of evaluation of
> shell.nix (that's a belief I inferred by observation; that is, I don't
> know for sure).
>
>
> Now, if I try launching GTK applications from within the shell.nix
> modified in this way, I get the same error message.  That may probably
> be due to the fact that my GTK applications were built against GTK 3,
> while you shell.nix requests GTK 2 (that's a guess, again).
>
> --
> Sergiu
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170614/28821694/attachment-0001.html>


More information about the nix-dev mailing list