Subject: bug#62547: --symlink option of "guix shell -C -F" is non-functional for /lib and /usr/lib, unlike /bin

From: Maxime Devos <[email-masked]>
Date: Thu, 30 Mar 2023 19:44:32 +0200

$ guix shell -F -C tk -- some-software
# ... libtk8.5 not found, let's choose version 8.5

$ LC_ALL=en_GB.UTF-8 guix shell -F -C [email-masked] shell
guix shell: error: tk: package not found for version 8.5

# Guix doesn't have version 8.5.  Let's lie and pretend
# that 8.5=8.6, maybe it will be ‘close enough’ for
# ‘some-software’.

$ guix shell -F -C tk --symlink=/lib/libtk8.5.so=/lib/libtk8.5.so -- 
some-software

guix shell: fout: symlink target is absolute: '/lib/libtk8.5.so'

tip: The target of the symlink must be relative rather than absolute, as 
it is relative to the profile created.
Perhaps the source and target components of the symlink spec were 
inverted? Below is a valid example, where the
`/usr/bin/env' symbolic link is to target the profile's `bin/env' file:

      --symlink=/usr/bin/env=bin/env

# Looks an arbitrary limitation to me -- the symlink code could just
# treat absolute targets as absolute instead of relative to the profile.
# Still, let's give following the tip a try.

$ LC_ALL=en_GB.UTF-8 guix shell -F -C tk 
--symlink=/lib/libtk8.5.so=lib/libtk8.6.so -- some-software
error: failed to evaluate directive: ("/lib/libtk8.5.so" -> 
"/gnu/store/sbvf4784c43ssr20x45icvm8s8h7zvh4-profile/lib/libtk8.6.so")
guix shell: error: symlink: Read-only file system: ".//lib/libtk8.5.so"

# If /usr/lib is tried instead of /lib, a different error occurs:

$ LC_ALL=en_GB.UTF-8 guix shell -F -C tk 
--symlink=/usr/lib/libtk8.5.so=lib/libtk8.6.so -- some-software

guix shell: error: symlink: File exists: "/usr/lib"

# Contrast this with /bin, in which files symlinks can be put, unlike
# /usr/lib and /lib (yes I know that putting libraries in /bin doesn't
# make much sense, it's just an example):

$ LC_ALL=en_GB.UTF-8 guix shell -F -C tk 
--symlink=/bin/libtk8.5.so=lib/libtk8.6.so -- some-software
guix shell: error: some-software: command not found
hint: Did you mean 'mtrace'?

Greetings,
Maxime.