Don Armstrong <d...@donarmstrong.com> wrote:
> Could you try changing /usr/bin/lilypond to be this instead:
> 
> #!/bin/sh
> export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/lilypond/2.18.2/guile"
> exec "lilypond.real" "$@"
> 
> and see if that works better?

No, I'm afraid not. That was the first thing I tried too, in the hope
that Lilypond was just checking for an _absolute_ path in its argv[0],
and might stop trying to be clever if you didn't give it one.

But no: it really does _search_ for its argv[0] value on PATH if it's
not already absolute. So if its argv[0] is just "lilypond.real", that's
just as bad as it being "/usr/bin/lilypond.real".

Demonstration transcript:

$ cat /usr/bin/lilypond
#!/bin/sh
export LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/lilypond/2.18.2/guile"
exec "lilypond.real" "$@"
$ export LILYPOND_DATADIR=$HOME/my-datadir
$ lilypond -V demo.ly
Log level set to 287
GNU LilyPond 2.18.2
Relocation: from 
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
argv0=lilypond.real
PATH=/usr/bin (prepend)
Setting PATH to 
/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Relocation: compile datadir=, new datadir=/usr/share/lilypond//2.18.2
Relocation: framework_prefix=/usr/bin/..
Setting INSTALLER_PREFIX to /usr/bin/..
Setting LILYPOND_DATADIR to /usr/share/lilypond//2.18.2
[...]

... and then it loads everything from /usr/share/lilypond/2.18.2 as
before.

That's why my actual workaround involved manually setting Lilypond's
argv[0] to something that it _couldn't_ find on PATH.

Now I think about it, an alternative workaround would be to make my own
bin directory alongside my intended datadir, symlink lilypond.real into
there, and ensure it precedes /usr/bin on my path. Then, when
lilypond.real looks for itself on PATH, it finds the version of itself I
wanted. But in order to do that, I still need lilypond.real's argv[0]
not to have an absolute path pointing somewhere else, so the current
/usr/bin/lilypond wrapper still makes that workaround awkward.

Incidentally, this seems to have been fixed upstream: if I check out
Lilypond master from git, it honours LILYPOND_DATADIR. I think the
commit that changed things was this one:
    https://sourceforge.net/p/testlilyissues/issues/5481/
but it's a full rewrite of the relocation algorithm, so probably not the
kind of thing it would be easy or desirable to cherry-pick into the 2.18
series :-(

Cheers,
Simon

-- 
for k in [pow(x,37,0x1a1298d262b49c895d47f) for x in [0x50deb914257022de7fff,
0x213558f2215127d5a2d1, 0x90c99e86d08b91218630, 0x109f3d0cfbf640c0beee7,
0xc83e01379a5fbec5fdd1, 0x19d3d70a8d567e388600e, 0x534e2f6e8a4a33155123]]:
 print("".join([chr(32+3*((k>>x)&1))for x in range(79)])) # <ana...@pobox.com>

Reply via email to