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

Sergiu Ivanov sivanov at colimite.fr
Wed Jun 14 22:57:40 CEST 2017


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 --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 487 bytes
Desc: not available
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170614/d1e7bc55/attachment.sig>


More information about the nix-dev mailing list